Factored out the common `w.Write(newlineBytes)` functionality.