Fix some possible fclose leaks