#308 optimized conditional checking for newline characters