The only way to improve this, is to return the html early and then use javascript to perform an AJAX request for another page which does the fread()
.. You could display a progress bar until the operation has finished.
Btw, for sockets there is socket_read()