tf = Hash.new
File.open("a.txt"){|io| io.read}.split(/\s/).each {|w| tf[w] = tf[w] ? tf[w] + 1 : 1}
p tf