On Wed, 2004-07-21 at 08:26 -0400, Lew Bloch wrote: > > Yes, I agree with you - I can either adjust the code or get back to my > > original question. :) How do I get an editor to not insert the trailing > > blank line ( LF line) rather than add it (with such editors as vi and > > nano)? > > You do not have a trailing blank line 4, as Craig pointed out. You have a > file with three lines, not 4, each ending in '\n'. The4re is no trailing > blank line. You cannot solve this, because the problem does not exist. The > file only has 3 lines, not 4. > > [...] > Or, to put it a little less Zen-like: it is standard Unix behavior to include a newline at the end of the last line of a file. In fact, when you open a file that has no such newline with some editors, they will warn you (I believe vi does this). If you want to see this fact in action, open an nedit session and type a line without hitting newline. As soon as you save, nedit will insert a newline, and you'll see another "line" show up in your file. However, since there are no characters in the line, the line does not really exist (other than the newline) unless you type something in it. So, if you are using some script to count lines, your logic should consider a newline character as the end of a line, not the beginning. (E.g. if you have one full line in your file with a newline at the end, you have 1 line, not two.)