Check out example codes for "unity add to txt file". It will help you in understanding the concepts better.

Code Example 1

public void WriteToFile(string filename, string data) 
    {        
        string FILE_PATH = "D:/" + filename; //full path to file 
        using (FileStream fs = new FileStream(FILE_PATH, 
          FileMode.Append))// set FileMode.Append to add data to file
                           // set FileMode.Create to create new file 
                           //   or overwrite existing file
        {
            using (StreamWriter writer = new StreamWriter(fs)) 
            {
                writer.Write(data);
            }
          
            fs.Close();
            fs.Dispose();
        }
    }

Learn ReactJs, React Native from akashmittal.com