w := bufio.NewWriter(transform.NewWriter(writeCloser, enc.NewEncoder()))
err = fn(w)
+ w.Flush()
if e := writeCloser.Close(); e != nil && err == nil {
err = e
if b.Settings["eofnewline"].(bool) {
end := b.End()
- if b.RuneAt(Loc{end.X - 1, end.Y}) != '\n' {
- b.Insert(end, "\n")
+ if b.RuneAt(Loc{end.X, end.Y}) != '\n' {
+ b.insert(end, []byte{'\n'})
}
}