For me, the trailing newline at the end of the file was not a problem, but having Unix line endings (\n) instead of Windows line endings (\r\n) broke the T4 engine.
Very frustrating to debug when you have two files that look identical but one of them won't compile!