Moved last_page_check to the top of the do...loop

It was always supposed to be there. Now it won't skip the last page.
Science!