fixed a bug when processing multiple output files