Fix file handling error