perl -pe "last if /^\s*$/" > filename.txt