If I've understood OP correctly, an empty line implies two consecutive newlines, \n\n.
If so, ondone possible solution would be to eliminate all singular occurrences of newlines.
In Perl, a lookahead assertion is one way to achieve this:
$ perl -0777 -pii -pe 's/\n(?=[^\n])//g' test
- The
-0777flag effectively slurps the whole file into a single string -ptells perl to print the string it's working on by default-ispecifies in-place editing- Global matching ensures that all single newline occurrences are dealt with