You do not need to parse every single line and then concatenate them again...
Source.fromFile(path)(Codec.UTF8).mkString
I prefer to use this:
import scala.io.{BufferedSource, Codec, Source}import scala.util.Trydef readFileUtf8(path: String): Try[String] = Try { val source: BufferedSource = Source.fromFile(path)(Codec.UTF8) val content = source.mkString source.close() content}