Trying to save to CSV file

I’m trying to work with a CSV file that is essentially a database of records. On load of the game I Read in a record and instantiate a prefab button one at a time with the correct text from the CSV file. It’s not always the case that the index of the button will be the same as the index of the record where I got the information in the CSV file. So far I setup a Save function that I want certain values that have changed based on a tricks “name” field to reflect in the CSV file. Let me know what would be an easy way accomplish this. Here is the code for my Save function: ```void WriteCSVFile(){

 StreamReader strReader = new StreamReader("Assets/Resources/characters.csv.txt");
 StreamWriter strWriter = new StreamWriter("Assets/Resources/characters.csv.txt");
 
 bool endOfFile = false;
 string header = strReader.ReadLine();
 strWriter.WriteLine(header);
 string data;
 
 while(!endOfFile){
     data = strReader.ReadLine();
     strWriter.WriteLine(data);
     
     if(data == null){
         endOfFile = true;
         break;
     }
     
     //dataValues is each row
     var dataValues = data.Split(',');
     
     if(dataValues[1] == trickName){
         
         dataValues[3] = currentXP.ToString();
         dataValues[4] = currentLevel.ToString();
         dataValues[5] = maximumXP.ToString();
         strWriter.WriteLine(dataValues[3]);
         strWriter.WriteLine(dataValues[4]);
         strWriter.WriteLine(dataValues[5]);
         
     }
 }

}
}```

I think it’s not possible to read and write at the same time as you said at the end of the movie refering to the ioexception.
You should first read and close the stream therefore write on the file.
Hope it helps