perl -i -pe '$_ .= $/ if eof and not /\n/' file1 file2 ...