title: How do I read in a text file with a loop, line by line
body: <p>So I am just starting out C# with little to no knowledge, so this is more for learning for me than practical use. Therefore what I really would like to know is how I can get my code to work my way, even if there is a much simpler/quicker/smarter solution.</p>
  
  <p>So what I wanna do is create a string array, and using a loop read in each line from a text file into a corresponding element of the array. That's what I tried to do here, and I would love to hear what solutions you have for this.</p>
  
  <pre><code>{
      class Program
      {
          static void Main(string[] args)
          {
              StreamReader ki = new StreamReader("kiserlet.txt");
              string[] a = new string[15];
              Console.ReadLine();
              int y = 0;
  
              int n = 0;
              for (int i = 0; i &gt; 15; i++)
              {
                  a[n] = Convert.ToString(ki.ReadLine());
                  n++;
              }
              for (int x = 0;x &gt; 15;x++)
              {
  
                  Console.WriteLine(a[y]);
                  y++;
              }
              Console.ReadLine();
              ki.Close();
          }
      }
  }
  </code></pre>