Fix file-handle leak