Please note that feof() used with TCP-Connections, returns false as long as the connection is open.
It even returns false when there is no data available.
BTW: Using feof() with HTTP for a single request, you should always make sure that you set the HTTP-Header "Connection" to "close" and _not_ to "keep-alive".