title: Writing a Text File in memory and saving it with savefiledialog
body: <p>I am trying to make a text file in memory, add some lines to it and at the end save the file in a text file. I can handle the savedialog part but I dont know how to get the text file from memory. Any help and tips will be appriciated.</p>
  
  <p>What I am doing so far is:</p>
  
  <pre><code>//Initialize in memory text writer
  MemoryStream ms = new MemoryStream(); 
  TextWriter tw = new StreamWriter(ms);
  
  tw.WriteLine("HELLO WORLD!");
  tw.WriteLine("I WANT TO SAVE THIS FILE AS A .TXT FILE!);
  </code></pre>
  
  <p><strong>please note</strong>
  I will call tw.WriteLine() add more lines in different places so I want to save this at end of program (so this shouldent be wrapped between something like using{} )</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>StringBuilder seems to be a more reliable option for doing this! I get strange cut-outs in my text file when I do it using MemoryStream.</p>
  
  <p>Thanks. </p>