M-% runs the command
query-replace, which prompts you first for the string to find, then the string to replace matches with. The enter key would normally close each of these prompts, so you have to do something special to search for or replace a newline.
Any time you want to type a character that would ordinarily have some other effect, you can prefix it with
C-q RET will enter the literal carriage return character, which is visually represented in a buffer as
However, your text file may or may not use carriage returns to indicate newlines. Most likely it uses line feeds instead. In this case you'll want to use
C-q C-J instead.
So, to put it all together: use
M-% C-q C-j C-q C-j RET C-q C-j RET to replace two line-feed characters in a row with a single line-feed character.
At each match the
query-replace command will ask you what to do. You can replace a single match, skip a match, or hit
! to replace all matches. There are a few other options as well.