Dude has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I have a perl web process that produces a data file on a Solaris BOX and emails a link for this file to the user when it completes. I write the data one line at a time with a "\n" concatenated to each line. When I open the file using vi on UNIX, the last line of data is the last line in the file. However, when I view the file from my PC via word pad or note pad, there is an extra blank line at the bottom of the file. I've run unix2dos on the file from my script before exiting to no avail and changed the EOL to \r\n with no luck. So, does Word Pad just read the EOF as a newline and EOF? Any help would be greatly appreciated. Thanks, Dude
  • Comment on extra blank line when user downloads onto PC from UNIX box

Replies are listed 'Best First'.
(tye)Re: extra blank line when user downloads onto PC from UNIX box
by tye (Sage) on Feb 13, 2001 at 03:48 UTC

    vi puts the cursor on top of characters. WordPad puts the cursor between characters so it is possible to place the cursor after the final newline. This puts the cursor past the end of the file, making it appear that it is on a blank line after the last line of the file.

            - tye (but my friends call me "Tye")
Re: extra blank line when user downloads onto PC from UNIX box
by kschwab (Vicar) on Feb 13, 2001 at 03:49 UTC
    This isn't really a Unix vs Windoze problem, it's an editor behavior problem.

    Vi likes the last character of the file to be a newline, wordpad does not. (see tye's note to see why)

    Change your script to print the last line without a trailing newline.

      Thanks Tye and Kschwab! Thank you both very much.