fix file opening bug