I'm a student who just started learning C#,
I'm trying to create Sign-Up and Login functions using text files, and save details that the user inputs into the textfile, but when I run my function again it rewrites what is already there instead of starting a new line.
This is a bit of my code that is important
using System;
using System.IO;
namespace SDD_Assessment_2
{
    class Program
    {
        static void Main(string[] args)
        {
            //Write();
            //GetTime();
            var privInfo = SignUp();
            var FullName = Profile(privInfo);
            Profile(privInfo);
            //Test(FullName);
        }
        const string filename = "Workout.txt";
        static string[] SignUp()
        {
            string[] privinfo = new string[4];
            Console.Write("First Name: ");
            privinfo[0] = Console.ReadLine();
            Console.Write("Last Name: ");
            privinfo[1] = Console.ReadLine();
            Console.Write("Email: ");
            privinfo[2] = Console.ReadLine();
            Console.Write("Password: ");
            privinfo[3] = Console.ReadLine();
            StreamWriter NewAccount = new StreamWriter(filename);
            //NewAccount.WriteLine(privinfo[0] + "," + privinfo[1] + "," + privinfo[2] + "," + privinfo[3] + Environment.NewLine);
            File.AppendAllText(filename, privinfo[0] + ", " + privinfo[1] + "," + privinfo[2] + "," + privinfo[3] + Environment.NewLine);
            NewAccount.Close();
            return privinfo;
        }
    }
}
When I run it right now, it says "System.IO.IOException: The process cannot access the file 'filename' because it is being used by another process."
 
     
     
    