in reply to How to remove newline characters at the end of file
perl -0pe '~s/\n+$/\n/' your-file [download]