ensure directory exists before making file