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: