public static void WriteWordCount(Dictionary<string, int> wordCount, string path) { using (StreamWriter file = new StreamWriter(path, false, Encoding.UTF8)) { foreach (var kvp in wordCount.OrderBy(v => v.Key)) { file.WriteLine("{0} {1}", kvp.Value, kvp.Key); } } }