add close and flush
use io.Writer instead io.WriteCloser
remove close