Fix crash with missing output directory/ unable to write.