The second and more semantically-consequential reason: when adding code to the last line of a file, if it didn't originally have a newline then diff (or git) will think that, in addition to the new code being added, the last line was also changed (because it was, because you added a newline to the end). So the output of the diff becomes less semantically accurate.

See how in the first example, diff sees the change as 2 existing lines being changed. In the second example, it sees the change as a single line insertion, with no existing lines modified (and doesn't do the ugly announcement of lack of newline).

Ahhh, isn't that nice? So, put newlines at the end of your code files!