Avoid accidental infinite loop if user misses %{index} in s3_object_key_format

This addresses #48 

Perhaps this is a very minor issue, but it cost me a lot so here it goes.

P.S. Apologies for the lack of style, I'm not a Ruby programmer. Had to change the loop because keeping that `begin end while` made code very unreadable with the new changes (at least to a non-Rubyist).