query_for_each_chunk fixed when query returns less than chunk_size
and does not call block when no results are returned