How to add newline character at end of file?

 
Hi All,
 
I have following piece of code in UNIX C Shell script and I want to add one more command which can add newline at the end of file only if there is no newline character exists.
 
   foreach file (`ls $dd_PLAYCARD_EDI_IN`)
    if ( -f $dd_PLAYCARD_EDI_IN/${file} ) then
      cat -n "$dd_PLAYCARD_EDI_IN/${file}"    | \
      perl -p -e "s/\x0d\x0a/\x0a/"  | \
      sed -e 's/00000000$/22991231/' | \
      sort -k1.18,1.29               >   $DATADIR/playcard/$file

Above "for loop" retrive the file from a directory then "cat" on each file to add line number, "perl" to remove ^M (control M) characters from the end of each line, "sed" will replace last 8 zeros with 22991231 and finally sort will sort the file. After "perl" command I want to add command which can add newline character at the end of file if it do not exists.
 
Please suggest.
 
Thanks!

Before you go on do read this post on why not csh.

Does the perl script really work?
IMHO should be

perl -p -e 's/\x0d$//'
 
I tried below command and it worked but it is adding one more line if there is already a blank line at the end of file.
 
perl -p -e "s/$/\x0a/"
 
I also cannot use any other Shell. Let me know if you have any other way to do it.
 
Thanks!

The -l option might do the trick:

perl -lpe 's/\x0d$//'

Please use 'ticks' not "quotes" for embedding perl code!