Check output file can be opened

Code would crash if output directory didn’t exist