Fix Null Pointer Exception thrown when bucket is empty

This error case is surprisingly common because most people running
this example will have just created a fresh bucket explicitly for
this purpose (like I had), and running into an exception immediately
that requires debugging isn't very friendly for the user.