Config files, pasted text and exports are full of blank lines. Removing them is two letters with awk.
awk NF file.txt > clean.txt
NF is the number of fields on the line. On an empty line it’s 0, and on a line with only spaces or tabs it’s 0 too, because the default field separator ignores whitespace. A pattern of 0 is false, so those lines don’t get printed. Any line with at least one word has NF of 1 or more and stays. An empty line and a line of three spaces both go; only lines with text stay.
That’s the advantage over grep -v '^$', which only drops lines that are truly empty and keeps the ones with a stray space. The grep equivalent is grep -v '^[[:space:]]*$', which I find harder to type correctly.
Combined with stripping comments, it’s a nice way to read a config file:
awk '!/^[[:space:]]*#/ && NF' /etc/ssh/sshd_config
Note that awk keeps the lines exactly as they were, leading spaces included. And the trick depends on the default separator: with -F,, a line of only spaces has one field and is kept.
Further reading: GNU awk manual, POSIX awk specification