Fix bug when opening files.