incomplete last line

How do I find through script if a contains "incomplete last line".
If it does then only insert a new line character as::
echo "" >> filename.txt

What did you try so far?

I tried doing::

awk 1 filename.txt > file1
mv file1 filename.txt

Its working fine but its touching all the other files which are correct. I have 100s of files. And this problem is in very few files. So I just want to apply the above command iff the file is a erroruos file.

Please help....

One way:

awk -v n=$(wc -l < file) 'END{if(NR != n)system("echo "" >> file")}' file

yippppiiiiiiii........
It worked.

Thank you very much....