awk 'NF && $1!~/^#/' data.txt
Print all non-empty lines (the number of NF fields will not be zero) and lines that do not contain # as the first field.
It will handle the string of spaces correctly, since NF will be zero, and leading spaces, since $1 will ignore them.
Levon source share