title: Are there any issues using a lambda expression in a foreach loop?
body: <p>I wrote a quick-n-dirty C# console application to search log files for string in another file. In one scenario, I passed in three files to search and one input file. The program loads all the values from the input file into memory as a list of objects. One of the properties of the objects is a boolean to mark the item as found.</p>
  
  <p>Because I am expecting each value in the input file to be found only once, I update the object's property to true and then break out of the loop that is walking through each line of the log files. When the break is in place, the application says that 18 items were not matched. When the break is commented out, all input values are found. There are no duplicate values in the input file. Is it possible that my lambda expression not behaving as I thought?</p>
  
  <pre><code>while ((line = sr.ReadLine()) != null)
  {
      foreach (var needle in needles.Where(d =&gt; d.Found == false))
      {
          if (line.Contains(needle.SearchValue))
          {
              needle.Found = true;
              //break; //works without break, misses some with break
          }
      }
  }
  </code></pre>
  
  <p>Sample of supposedly missing rows:</p>
  
  <pre><code>Completed Document 48166115
  Completed Document 48166120
  Completed Document 48371705
  Completed Document 48371710
  Completed Document 48371720
  </code></pre>
  
  <p>Sample of log that contains some of these values:</p>
  
  <pre><code>06/20/13 20:53:22 - Completed Document 48132000, 2 pages
  06/20/13 20:53:23 - Completed Document 48166115, 2 pages
  06/20/13 20:53:23 - Completed Document 48166116, 2 pages
  06/20/13 20:53:23 - Completed Document 48166117, 2 pages
  06/20/13 20:53:23 - Completed Document 48166118, 2 pages
  06/20/13 20:53:24 - Completed Document 48166119, 2 pages
  06/20/13 20:53:24 - Completed Document 48166120, 2 pages
  06/20/13 20:53:24 - Completed Document 48166121, 2 pages
  </code></pre>