Added an error check if the output directory already exists so that the process can be terminated quickly.