Stopping when the results is less than the first param is an unreliable way to paginate even if this was working perfectly.
The reason is, if the total number of streams is a multiple of your first param the final page would have a results equal to first, and because it still has a cursor (Get Streams endpoint has a cursor on the final page to allow for traversal of results in either direction) if you blindly attempt to use that cursor as the after value it’ll loop you back to the start and you’ll just endless loop.
To properly paginate the Get Streams endpoint you need to not assume that results < first is the end, as there could still be more pages. You also need to retry any bad cursors, such as IA. And you need to detect looping, this can either be done through a check of the cursor length/decoding, or by comparing the results you’re getting to the results you’ve previously collected (if you jump from results with 1 or 0 viewers, to a page of streams with hundreds or thousands, you’re back at page 1)