It is possible to read faster than it is transmitted hence seeing a zero. One improvement is to add a read timeout. I.E.: keep reading although a zero is returned until the timeout, then exit the loop.
Another improvement would be to know the exact size of the download so you don't have to always use the timeout. You can exit when the entire file is read.
You can also utilize the connected() function if the connection dies and there are no bytes to read.