Fix file descriptors leaks

I think these are file descriptors leaks ?