use bufio to implement file writer