If the TCP server is keeping the connection open (that is, not doing a C
close(2) on the socket) and if the server does not set the PSH (push) bit on the TCP segments containing the newlines, the last portion of data may not make it to your application for some time.
If you control the application server, you can likely control the first aspect: closing the socket. You may or may not be able to cause the PSH bit to be set.
As wog noted, sysread returns 0 (the number of bytes read) on EOF, but it is only EOF iff the socket is closed by the server.
--traveler