() C K Kashyap <ckkashyap@gmail.com>
() Fri, 22 Jul 2011 15:32:10 +0530

  However, I'd like the
  result to not leave blank lines.

Try ‘M-x flush-lines’.
Use ‘C-h f flush-lines RET’ first to avoid surprises.

this does exactly what I was looking for.
Kashyap