Prevent possible infinite loop

If the server returned too few data, the script would hang waiting for
more. Detect no data and abort.