add missing close(), use rdbuf()
misc. update
merge