I have a small program that I want to use to delete all lines in a file after a certain line. It works fine except it puts a newline (I assume an '\n') at the end, whereas I don't want any blank line at the end. I thought the way it is written would avoid this, but apparently not. Any ideas?
How do you know there is a new line character at the end? Have you opened the file in a hex editor? Many text editors automatically appends a new line character at the end if one is missing.