How to remove blank line from a text file?

Hi All,

I am creating a text file using perl. The first record I am writing as "$line" and all the other as "\n$line". At the end the file is having N number of lines. I am using this file for MLOAD (Teradata), which is reading N+1 lines in the file and failing.I am not able to find new line character or any special char at the end of the last record which may cause this issue and there is only 6 records visible.
Then I tried "sed '/^$/d' oldfile > newfile" and used New file for MLOAD. In new file it is showing 6 complete rows and 1 blank.(MLOAD is failing again). Can you please help.

Thanks.

That sed ought to have removed blank lines, it works here.

So I suspect the line isn't actually blank.

Try hexdump -C filename | less to review ASCII codes for the data to see if you can find what's in the 'blank' line.

I couldn't say why your code's making these lines without seeing your code.

Why not write all the lines as as "$line\n" ? A line terminator needs to be at the end of the line.