Fix too early StopIteration on empty result sets

Fixes #77, thanks to @hfaran for report