Fix errors on opening file