Really new to c#, sorry if its a simple question. When trying to write a randomised user entered array on a file, the input names are not saved correctly.
Code:
using System;
using System.Linq;
using System.IO;
namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] lines = System.IO.File.ReadAllLines(@"C:\Users\dvfsn\Desktop\Coding\cSharp testing\studentnames.txt");  
            Random rnd = new Random();
            Console.WriteLine("Do you want to read or write data?");
            switch(Console.ReadLine()){
                case "write":
                     string[] names = new string[10];
                    for (int i = 0; i < names.Length; i++) 
                    {
                        Console.WriteLine("Enter names {0}", i);
                        names[i] = Console.ReadLine();
                        names = names.OrderBy(x => rnd.Next()).ToArray();
                        File.WriteAllLinesAsync("studentnames.txt", names);                    
                    }
                break;
                case "read":
                    Console.WriteLine("name of data you want to read?");
                    switch(Console.ReadLine()){
                        case "names":
                            Console.WriteLine("the contents include:");
                            foreach (string line in lines){
                                Console.WriteLine("\t" + line);
                            }
                        break;
                    }
                break;
            }
            Console.ReadLine();
        }
    }
}
Result:

This may be too much to ask but if you could explain the solution that would be really helpful. Thanks
 
     
    