exit from while if fread return an empty string

In case of a read timeout, fread return an empty string and not false.

We need to exit the while loop in this case, if we don't, we loop forever.

Alternatively, we could read the 'timed_out' status from stream_get_meta_data like in the write method.