Added check for duplicate files in output directory