Here I would replace `lastBytePosition.map(_.toString).getOrElse("")` with

    ... ~~ {
      lastBytePosition match {
        case Some(x) => x.toString
        case _ => ""
      }
    }

and save the creation of two closures.