func (w *MaxLineWriter) Write(data []byte) (int, error) {
	if len(data) == 0 {
		return 0, nil
	}
	checkMax := w.MaxLines > 0
	if checkMax && w.NumLines >= w.MaxLines {
		return 0, MaxLinesErr
	}
	var err error
	byteCnt := 0
	for i, b := range data {
		if b == byte('\n') {
			w.NumLines++
			if checkMax && w.NumLines > w.MaxLines {
				err = MaxLinesErr
				break
			}
		} else if checkMax && w.NumLines >= w.MaxLines {
			err = MaxLinesErr
			break
		}
		byteCnt = i
	}
	cnt, err1 := w.Dest.Write(data[:byteCnt+1])
	if err1 != nil {
		return cnt, err1
	}
	return cnt, err
}
Write() stops writing and returns an error if an attempt is made to write
any byte after |MaxLines| newLines have been written. For example, if MaxLines
is 1, all bytes will be written up to and including the 1st newline. If there
are any bytes in |data| after the 1st newline, an error will be returned.

Callers can change the value of |w.MaxLines| before any call to Write().
Setting MaxLines to 0 will allow any number of newLines.
package writers
import "io"
var (
	MaxLinesErr = MaxLinesError{"Maximum number of lines written"}
)
type MaxLinesError struct {
	msg string
}
func (e MaxLinesError) Error() string { return e.msg }
type MaxLineWriter struct {
	Dest     io.Writer
	MaxLines uint32
	NumLines uint32
}