move next_line out of Connection class