title: StreamWriter in a Unity C# program
body: <p>I have written the following code in order for my Unity app to write something to file:</p>
  
  <pre><code>using UnityEngine;
  using System;
  using System.Collections;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.IO;
  
  public class StreamManager : MonoBehaviour
  {
      void Start ()
      {
          WriteToFile();
      }
  
      void Update ()
      {}
  
      public static void WriteToFile()
      {
          StreamWriter sw = new StreamWriter( Application.persistentDataPath + "table.txt" );
  
          sw.WriteLine( "Generated table of 1 to 10" );
          sw.WriteLine( "" );
  
          for ( int i = 1; i &lt;= 10; i++ )
          {
              for ( int j = 1; j &lt;= 10; j++ )
              {
                  sw.WriteLine( "{0}x{1}= {2}", i, j, (i*j) );
              }
  
              sw.WriteLine( "====================================" );
          }
  
          Console.WriteLine( "Table successfully written to file!" );
  
          sw.Close();
      }
  }
  </code></pre>
  
  <p>However, the last line (<em>Table successfully written to file!</em>) is not written to the text file.</p>
  
  <p>Why is that?  What am I missing here?</p>
  
  <p>Thank you,</p>