Fixing bug where results_in_batches + zero results would yield an infinite loop