The Python docs on file.read() state that An empty string is returned when EOF is encountered immediately.
The documentation further states:
Here's what my C compiler's documentation says for the fread()
function:
size_t fread(
void *buffer,
size_t size,
size_t count,
FILE *stream
);
fread returns the number of full items actually read, which may be less than count if an error occurs or if the end of the file is encountered before reaching count.
So it looks like getting less than size
means either an error has occurred or EOF has been reached -- so break
ing out of the loop would be the correct thing to do.