Correct a bug in creating directories as needed for output.