Fix fd leak noticed by Barry Haddow