fix issue with file array being modified