title: Enhancing performance of streamwriter in c#
body: <p>in my program i need to write large text files (~300 mb), the text files contains numbers seperated by spaces, i'm using this code :</p>
  
  <pre><code>TextWriter guessesWriter = TextWriter.Synchronized(new StreamWriter("guesses.txt"));
  
  private void QueueStart()
      {
          while (true)
          {
              if (writeQueue.Count &gt; 0)
              {
                  guessesWriter.WriteLine(writeQueue[0]);
                  writeQueue.Remove(writeQueue[0]);
              }
          }
      }
  
  private static void Check()
      {
          TextReader tr = new StreamReader("data.txt");
  
          string guess = tr.ReadLine();
          b = 0;
          List&lt;Thread&gt; threads = new List&lt;Thread&gt;();
          while (guess != null) // Reading each row and analyze it
          {
              string[] guessNumbers = guess.Split(' ');
              List&lt;int&gt; numbers = new List&lt;int&gt;();
              foreach (string s in guessNumbers) // Converting each guess to a list of numbers
                  numbers.Add(int.Parse(s));
  
              threads.Add(new Thread(GuessCheck));
              threads[b].Start(numbers);
              b++;
  
              guess = tr.ReadLine();
          }
      }
  
      private static void GuessCheck(object listNums)
      {
          List&lt;int&gt; numbers = (List&lt;int&gt;) listNums;
  
          if (!CloseNumbersCheck(numbers))
          {
              writeQueue.Add(numbers[0] + " " + numbers[1] + " " + numbers[2] + " " + numbers[3] + " " + numbers[4] + " " + numbers[5] + " " + numbers[6]);
          }
      }
  
      private static bool CloseNumbersCheck(List&lt;int&gt; numbers)
      {
          int divideResult = numbers[0]/10;
          for (int i = 1; i &lt; 6; i++)
          {
              if (numbers[i]/10 != divideResult)
                  return false;
          }
          return true;
      }
  </code></pre>
  
  <p>the file data.txt contains data in this format : (dots mean more numbers following the same logic)</p>
  
  <pre><code>1 2 3 4 5 6 1
  1 2 3 4 5 6 2
  1 2 3 4 5 6 3
  .
  .
  .
  1 2 3 4 5 6 8
  1 2 3 4 5 7 1
  .
  .
  .
  </code></pre>
  
  <p>i know this is not very efficient and i was looking for some advice on how to make it quicker.
  if you night know how to save LARGE amount of numbers more efficiently than a .txt i would appreciate it.</p>