Use a tryexcept block to read from the input files and write to the output file