The program works, however, I still get a logical error: the final letter doesn't run through. For example, when I enter aaaabbbbccccdddd the output I get is a4b4c4 but there is no d4.
fun main () {
    val strUser = readLine()!!.toLowerCase()
    val iLength = strUser!!.length
    var iMatch : Int = 0
    var chrMatch : Char = strUser[0]
    for (i in 0..iLength) {
        if (strUser[i] == chrMatch) {
            iMatch += 1
        }else {
            print("$chrMatch$iMatch")
            chrMatch = strUser[i]
            iMatch = 1
        }
    }
}
 
     
     
     
    