forEachLine
Reads this file line by line using the specified charset and calls action for each line. Default charset is UTF-8.
fun File.forEachLine(charset: Charset = Charsets.UTF_8, action: (line: String) -> Unit)(source)
import java.io.File
fun main() {
val file = File("example.txt")
file.forEachLine { line ->
println(line)
}
}