changed the logic a bit so that the \r and \r\n are split upon