title: How to delete line from CSV as they are read in Bash
body: <p>I am currently doing this:</p>
  
  <pre><code>while read l
  do
    echo git add $l/
    git add $l/
    # sed -i -e '1,1d' data/commit-folders.csv
    # echo git commit -am "'Autocommit'"
    # git commit -uno -am "'Autocommit'"
    # echo git push origin master
    # git push origin master
  done &lt; data/commit-folders.csv
  </code></pre>
  
  <p>Essentially just <code>git add &lt;folder&gt;</code> for a list of folders in a CSV file. I would like for this to be more robust, in that every time it restarts it restarts from where it left off. So I added that commented out line which does an in-place delete <code>sed -i -e '1,1d' data/commit-folders.csv</code>. However, with <code>while read line</code>, it messes up with the current line if they are being deleted. So I'm wondering how to do this properly.</p>
  
  <p>How to iterate through a CSV file with <code>&lt;path&gt;</code> on each line, and delete the path once it is successfully git added. It seems like you need to have a loop that selects the first line from a file, and then deletes it from the file afterwards, rather than using <code>while read line</code>.</p>