Golang – Write Text to File Line by Line

Last Updated on

This post briefly demonstrates how to write texts to a file line by line in Go using buffered IO or bufio.


bufio is a Go package that comes with the Go SDK and it has the Writer type that we need to write lines to a file line by line.

Lines to Write

We have the following texts to write.

The Codes



Please visit https://golang.org/ for more information.

Karl San Gabriel

Karl San Gabriel

Professional Software Developer