Fix how the lines are split.

In node the 'a\n'.split('\n') would result in ['a', ''], so when the
generated line has '\n' as tail we would get an extra empty line.