move linefeed detection to proper function