$ sed -e 's/[[:space:]]*$//' -e '/./!d' file.txt