title: Breaking the each loop in Groovy
body: <p>How will I break the loop if a particular condition is satisfied?</p>
  
  <p>My input file has around n number of lines. If the required information is got at some mth line I need to break the loop instead of reading the remaining lines.</p>
  
  <pre><code>new File("test.txt").readLines().reverseEach{line -&gt;
     println line
  
     if(line.contains("Data"))
     break;
   }  
  </code></pre>