As you describe it, you say it gets all the matches, and then doesn't move to the next page. That suggests the problem isn't in
. It may be in "Do something". It may be in whatever you using the get the next page. It may be a network problem. It may be a problem on the server you're fetching from. And if you hadn't ruled it out already, it may be that the pattern takes a really long time to determine there's no match.
But I have to say, you give extremely little information. It's just guessing what could be wrong with your program.