title: C# listbox array trouble
body: <p>All. I am creating a program that takes a list of teams as a string array and compares it to a .txt file that contains a list of all the World Series winners and determines how many times a team has won the World Series based off which Team you select in a list box. </p>
  
  <p>My code is throwing 0 errors and the first time I ran the program and selected a team and clicked the button it showed the messagebox displaying the team name and how many times they won. After that, whenever I would choose a team again and click the button, nothing happens. It just freezes. I have to then stop debugging. What could have possibly went went wrong? Any thoughts and advice? </p>
  
  <pre><code>namespace WorldSeriesWinners
  {
      public partial class Form1 : Form
     {
          string[] inputTeams = 
          { 
            "Boston Americans", "New York Giants", "Chicago White Sox","Chicago Cubs",
            "Pittsburgh Pirates", "Philadelphia Athletics","Boston Red Sox", "Boston Braves",
            "Cincinatti Reds", "Cleveland Indians","Brooklyn Dodgers",
            "New York Yankees", "Washington Senators", 
            "St. Louis Cardinals","Detroit Tigers", "Milwaukee Braves",
            "Los Angeles Dodgers", "New York Mets", "Baltimore Orioles",
            "Oakland Athletics", "Philadelphia Phillies", "Kansas City Royals", "Minnesota Twins", "Toronto Blue Jays", 
            "Atlanta Braves", "Florida Marlins", "Arizona Diamondbacks", "Anaheim Angels", "San Francisco Giants"
          };
  
      string[] worldseriesWinners = new string[104];
  
      public Form1()
      {
          InitializeComponent();
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          listBox1.Items.AddRange(inputTeams);
      }
  
  
  
      private void button2_Click(object sender, EventArgs e)
      {
          StreamReader champFile = File.OpenText("WorldSeriesWinners.txt");
          List&lt;string&gt; inputTeams = new List&lt;string&gt;();
          string selectedTeam;
  
          while (!champFile.EndOfStream)
          {
              inputTeams.Add(champFile.ReadLine());
          }
          while (listBox1.SelectedIndex != 0)
          {
              selectedTeam = listBox1.SelectedItem.ToString();
          }
          selectedTeam = listBox1.SelectedItem.ToString();
          var count = File.ReadLines("WorldSeriesWinners.txt").Count(x =&gt; x.Contains(selectedTeam));
  
          if (count &gt; 0)
          {
              MessageBox.Show("The " + selectedTeam + "has won the World Series " + count + " times! ");
          }
          else
          {
              MessageBox.Show("The " + selectedTeam + "has never won the World Series.");
          }
      }
  }
  </code></pre>