How does this work when there are several files processed in parallel.  This looks fishy to me.