Would it work here to just do:

    val logText = <node> {lines.slice(offset, offset+lineLength).mkString("\n")} </node>