Fixed a bug that caused the temporary files to be merged in the wrong order