Fixed resource collection loop.

next_page is 0, and not a nil value as had been expected, when the collection is on the last page.