Fix file handle retrieval