Sorting dictionary according to letter patterns
This can be improved and shortened by naming the concepts you are using:


A function called encodeWord that takes a single word and returns its encoded value
A function called groupedByCodes which takes an array of words, and returns the object you are seeking: codes as keys, and arrays of words that get encoded to those keys.


This will have the following benefits:


What your code is doing will be crystal clear.
You'll have less code
Most of your temporary variables will vanish


I've also purposefully left out the writing and reading of the files, as that's really a separate concern from your main program.  

Rewriting it this way, you'll get something that looks like this:

var sampleFile = "CAT\nDOG\nTOM\nBOB\nTOT",
    words = sampleFile.split("\n");

console.log(groupedByCodes(words));
// { ABC: [ 'CAT', 'DOG', 'TOM' ], ABA: [ 'BOB', 'TOT' ] }

function groupedByCodes(words) {
  return words.reduce(function(dict, word) {
    var code = encodeWord(word);
    if (!dict[code]) dict[code] = []; 
    dict[code].push(word);
    return dict;
  }, {});
}

function encodeWord(word) {
  var encodingDict = {}, nextCode = 65; //'A'
  return word.split('').map(encodeLetter).join('');

  function encodeLetter(l) {
    return encodingDict[l] || (encodingDict[l] = String.fromCharCode(nextCode++));
  }
}