perl -ni.bak -e "print $_ unless /^[\n\s]+$/;" my_file.txt