def readnoncommentline(file):
    """Read a line from the text file, skipping blank and comment lines that begin with #"""

    line = ''

    while not line.strip() or line.strip().lstrip().startswith('#'):
        line = file.readline()

    return line