Fix File descriptor leak related to GH-1324.

Following my comment on the code, here is the fix for issue #1324 !


Thanks @FooBarWidget for your work !