Fixed bug on opening files