Don't append for first iteration

The first iteration of the appending function should be a write operation to overwrite the previous output file.
looks like a blooper. could you remove the `app`?