move the newline logic into #handle_stream