Groovy script to modify text file line by line
<p>I have a input file from which a Groovy file reads input. Once a particular input is processed, Groovy script should be able to comment the input line it used and then move on.</p>

<p>File content:</p>

<pre><code>1   
2        
3
</code></pre>

<p>When it processes line 1 and line 2, the input file will look as below:</p>

<pre><code>'1    
'2                   
3
</code></pre>

<p>By this way, if I re-run the Groovy, I would like to start from the line it stopped last time. If a input was used and it failed, that particular line shall not be commented (<code>'</code>) so that a retry can be attempted.</p>

<p>Appreciate if you can help to draft a Groovy script.</p>

<p>Thanks</p>