Adding word frequency logging functionality