Did away with redundancy in reading entire file before building dictionary in Ruby.