Fixed file handle leak