Fixed a bug at file opening