title: check if string exists in a file
body: <p>I have the following piece of code which <strong>opens a text</strong> file and reads all the lines in the file and storing it into a string array. </p>
  
  <p>Which then checks if the string is present in the array.
  However the issue I'm facing is that whenever a string is found, it always shows <strong>"there is a match"</strong> as well as "there is no match". <strong>Any idea how to  fix this?</strong></p>
  
  <p><strong>check this code:</strong></p>
  
  <pre><code>using (StreamReader sr = File.OpenText(path))
  {
      string[] lines = File.ReadAllLines(path);
      for (int x = 0; x &lt; lines.Length - 1; x++)
      {
          if (domain == lines[x])
          {
              sr.Close();
              MessageBox.Show("there is a match");
          }
      }
      if (sr != null)
      {
          sr.Close();
          MessageBox.Show("there is no match");
      }
  }
  </code></pre>