Fixed file opening bug