title: Read All Lines in a Text File and Add Them C#
body: <p>I've been working on this problem for a while and I'm a little stuck.  I have a text file that I need to loop through and read all lines of, then add all of the substrings together for one final number.  The problem is, what I have is reading correctly and producing the number for the first line in the file only.  I'm not sure whether to use 'while' or 'for each'.  Here is the code I have:</p>
  
  <pre><code>    string filePath = ConfigurationSettings.AppSettings["benefitsFile"];
      StreamReader reader = null;
      FileStream fs = null;
      try
      {
          //Read file and get estimated return.
          fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
          reader = new StreamReader(fs);
          string line = reader.ReadLine();
          int soldToDate = Convert.ToInt32(Convert.ToDouble(line.Substring(10, 15)));
          int currentReturn = Convert.ToInt32(soldToDate * .225);
  
          //Update the return amount
          updateCurrentReturn(currentReturn);
  </code></pre>
  
  <p>Any suggestions would be much appreciated.</p>