title: Read data from a file and assign them to variables
body: <p>I need to read data from a file, so I have this code.</p>
  
  <pre><code>public static void readData()
  {
      TextReader readFile;
      string chain;
      bool found = false;
      string[] fields = new string[2];
      char[] breakUp = { ':' };
  
      try
      {     
          readFile = new StreamReader("C:\\Users\\unam\\Documents\\Hugo\\Datos.txt");
  
          chain = readFile.ReadLine();
          while (chain != null)
          {
              fields = chain.Split(breakUp);
  
  
              if (fields[0].Trim().Equals("Name"))
              {
                  name = fields[1].Trim();            
              }
              else
              {
                  if (fields[0].Trim().Equals("Age"))
                  {
                      Age = fields[1].Trim();    
                  }
              }
              readFile.Close();
  
           }
      }
      catch(FileNotFoundException fe)
      {
          Console.WriteLine("¡File not found!" + fe.Message);
      }
      catch(Exception e)
      {
          Console.WriteLine("¡File not found!" + e.Message);
      }
  }         
  </code></pre>
  
  <p>And in the document I have </p>
  
  <ul>
  <li>Name: Hugo</li>
  <li>Age: 23</li>
  </ul>
  
  <p>When I execute the code it stays in a loop in the first if so it just reads the name again and again, my question is, how can I get out of that loop to read the other data?</p>