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

alternatively, we could read the 'timed_out' status from stream_get_meta_data like in the write method