fclose properly, 0 on coreio_open fail
Remove dead code