perl -i -pe 'BEGIN{$/="\n\n"} s/\n\n/\n/;' foo.txt