For
- If you cat a file without a trailing newline your prompt may appear at the end of the output instead of flush left.
- Some C++ compilers complain when there is no trailing newline.
- Each line in the file ends in a newline.
wc -lreports an incorrect result if it is missing- More reasons
Against
- git considers a trailing newline a whitespace error.
- Trailing whitespace is easily lost when, for example, exchanging patches via email.
- A newline after a closing “?>” in PHP can cause problems with
header()(although closing tags are no longer required in PHP). - It uses one more byte.
