def make_anagram_dict(filename):
    """Takes a text file containing one word per line.
    Returns a dictionary:
    Key is an alphabetised duple of letters in each word,
    Value is a list of all words that can be formed by those letters"""
    result = {}
    fin = open(filename)
    
    for line in fin:
        word = line.strip().lower()
        letters_in_word = tuple(sorted(word))

        if letters_in_word not in result:
            result[letters_in_word] = [word]
        else:
            result[letters_in_word].append(word)
    return result