the check for ```len(line) < 1``` will never actually happen if the line is indeed length 0, since ```line[0]``` will raise an ```IndexError```.  Instead, use ```if line and line.startswith('#')```