Some minor refactoring in the insert newline operation