in reply to How to remove newline characters at the end of file

A shorter command line version.
perl -0pe '~s/\n+$/\n/' your-file
cheers