Move line reading code to Connection