fix bug: FileMode is set to 0 in OpenFile