Surely you don't need the message to be broken up into lines just for that. Just read until a threshold is reached and then close the connection.