def get_next_line(lines, iline):
    """Read the next line from the file.  Handles comments."""
    try:
        line = lines[iline].strip()
    except IndexError:
        line = None
        return iline, line
    iline += 1
    igap = 0
    ngap_max = 10
    while len(line) == 0 or line[0] == '#':
        try:
            line = lines[iline].strip()
        except IndexError:
            line = None
            return iline, line
        iline += 1
        if igap > ngap_max:
            break
        igap += 1
    return iline, line
