Refactoring(sane newline handling)