Kotlin has a specific extension for reading contents of InputStream.
val inputAsString = input.bufferedReader().use { it.readText() }
You can try reading about this at this stack overflow post: In Kotlin, how do I read the entire contents of an InputStream into a String?