fix some file descriptor leaks

Some file descriptors not closed, you notice those things when browsing book...