awk '!/^#/ && !/^$/{c++}END{print c}' "file"
awk '!/^[ \t]*(#|$)/ {c++; ct++} /#/ && c { printf "%s\n\n\n%s", c, $0; c=0} END { print ct}' file