Remove comments and empty lines with grep

grep -v -e ^# -e ^$ file.txt