func writeLines(w io.Writer, lines []string) error {
	for _, line := range lines {
		_, err := fmt.Fprintln(w, line)
		if err != nil {
			return err
		}
	}
	return nil
}
Write some lines to an io.Writer.
package gogroup
import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"io/ioutil"
	"sort"
	"golang.org/x/tools/imports"
)
func readLines(r io.Reader) ([]string, error) {
	scanner := bufio.NewScanner(r)
	ret := []string{}
	for scanner.Scan() {
		ret = append(ret, scanner.Text())
	}
	if scanner.Err() != nil {
		return nil, scanner.Err()
	}
	return ret, nil
}