Why do some of the more technical apps require newlines at the end of files? I've read it has something to do with diffs, but shouldn't diff be able to figure the relative positions of things out on its own?

up vote 6 down vote accepted

Text file are composed of text lines, which are terminated with newlines (as opposed to being separated by newlines). So omitting the last newline technically makes the last line an incomplete text line.

I think it has more to do with appending to the end of the file. The convention is to have a newline at the end so that anything adding to the file doesn't have to worry about whether they need to make a break between the old content and the new.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.