def read_dict_text(fn):
    """
    Read a dictionary with several sections from plain text format. Section is denoted by first character being '#'.
    Returns dictionary of lists
    :param fn: filename
    :return: Dictionary with a list of lines for each section
    """
    dict = {}
    lines = []
    prevsec = ""
    with open(fn) as f:
        for x in f.readlines():
            x = x.strip()
            if x[0]=='#': # section
                if len(lines)>0 and prevsec!="":
                    dict[prevsec] = lines
                    lines=[]
                    prevsec = x[1:]
            else:
                lines.append(x)
    if len(lines) > 0 and prevsec != "":
        dict[prevsec] = lines
    return dict