how to read and write multiple files?,output.close()