Assignment not allow in while expression?

How can I simplify the following similar code without performance reduce:

randomAccessFile.seek(offset)

var byteCount = randomAccessFile.read(buffer)
while (byteCount != -1){
    fos.write(buffer, 0, byteCount)
    byteCount = randomAccessFile.read(buffer)
}
1 Like