- Github and git will highlight a missing newline in a diff by default.
- POSIX defines a line as having a newline at the end, so if you don't have a terminating new line you may have one fewer lines than you think you have [1]
- If you ever want to append to a text file/source file programmatically with something like echo "something at the end" >> yourfile.txt then you'll be grateful you had the habit of ending everything with a newline.
- If you use a shell that doesn't automatically add one when you do cat filename you'll end up with your prompt sitting awkwardly at the end of the file.
vim, iirc, defaults to automatically adding a newline to any file without you explicitly asking for it, unless you do set noeol and set binary or, in versions newer than 7.4, set nofixendofline
[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1...
which, IMO, is the right way to do it. In kakoune however, it isn't just the default, there is no way to turn it off.
> echo hello > hello
> echo -n hello > hellon
> wc hello hellon
1 1 6 hello
0 1 5 hellon
1 2 11 total