title: how to write console output to a text file in vb.net
body: <p>I'm currently faced some problem which is cannot convert/transfer the console output the a specific text file. I'm also tried use the below code. The problem is, it only can write first line from the console and the following line is cannot write to the text file and also the console is exit. Anyone help me please.</p>
  
  <p>Regards,
  Thanes</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.IO;
  
  namespace consoletotext
  {
      class Program
      {
          static void Main(string[] args)
          {
              string firstname;
              string myoutline;
              Console.Write(""); // whatever type here
              firstname = Convert.ToString(Console.ReadLine());
              string path = @"file.txt";
              myoutline = firstname;
  
              if (!File.Exists(path))
              {
                  using (StreamWriter sw = File.CreateText(path))
                  {
                      sw.WriteLine(myoutline);
  
                  }
              }
              Console.ReadKey();
  
          }
  
  
      }
  }
  </code></pre>