Fix double-fclose bug diagnosed by Christian Eder.