Try creating directory if file write fails