Fix file descriptor leak
Merge pull request #1 from tsdunc/fdleak-fix

Fix file descriptor leak