You need to create an immutable copy of word before using it as a key. That is, replace this line:
> dictionary[word] = newID; with dictionary[word.idup] = newID;
You need to create an immutable copy of word before using it as a key. That is, replace this line:
> dictionary[word] = newID; with dictionary[word.idup] = newID;