Removing extra blank lines in Emacs

If you want to get rid of extra blank lines in your text files, you can use the search and replace commands with regular expressions. However, for whatever reason, this does not work properly on my Windows machine.

Fortunately, I found a nice function definition at stackoverflow which does the job:

http://stackoverflow.com/questions/4419576/delete-extra-blank-lines-in-emacs