When consecutively inserting data into an existing directory, each files must have different names. To avoid the duplicated name problem, a unique sequence number is appended to the end of the file name. In addition, the max sequence number of pre-existing files is first found before starting writing to the final output directory.
When finding the max sequence number of pre-existing files, those files are not sorted by their sequence numbers. This finally causes the duplicated file name problem.