finished code to output word frequency files