title: Input Text File and Read First Character of Each Line + Count Occurences
body: <p>I'm trying to count the number of occurrences of the first character per line of a text file. </p>
  
  <p>Example text file: </p>
  
  <blockquote>
    <p>A</p>
    
    <p>Ab</p>
    
    <p>Ac</p>
    
    <p>Ad</p>
    
    <p>B</p>
    
    <p>Ba</p>
  </blockquote>
  
  <p>Example output: </p>
  
  <blockquote>
    <p>A : 4</p>
    
    <p>B : 2</p>
  </blockquote>
  
  <p>Here's the code that I have so far, the issue is that it doesn't know which characters are the same so there multiple iterations of A, B, C, D, etc...</p>
  
  <pre><code>    string line;    
      char firstChar;        
      private void selectFile()
      {
          openFileDialog1.Title = "Open Text File";
          openFileDialog1.Filter = "Text|*.txt";
          openFileDialog1.InitialDirectory = @"C:\";
          openFileDialog1.FileName = "";
          openFileDialog1.ShowDialog();
  
          if (openFileDialog1.ShowDialog() == DialogResult.OK)
          {
              readFile();
          }
      }
  
      private void readFile()
      {
          int counter = 0;
  
          StreamReader readTxt = new StreamReader(openFileDialog1.FileName);
          while ((line = readTxt.ReadLine()) != null)
          {
              charFreq();            
              counter++;
          }
      }
  
      private void charFreq()
      {
          firstChar = line.ToCharArray()[0];
          var charFreq =
              from c in firstChar.ToString().ToCharArray()
              group c by c into groupFrequencies
              select groupFrequencies;
  
          foreach (var c in charFreq)
              rTxtOutput.Text += (String.Format("{0} : {1}", c.Key, c.Count())) + "\r\n";
      }
  </code></pre>
  
  <p>What would be the proper way to do this? Thanks!</p>