Fix for the case a directory of the output file does not exist