This is a program that takes lines from 'wordList' and prints it's anagrams, found in the dictionary.Please give me feedback regarding good coding practices. import java.io.Filefun main(arg: Array<String>) {    val wordList =            File(wordList.txt)                    .readLines()    for (word in wordList) {        val sortedWordChar =                word                        .toCharArray()                        .sorted()        val dictionary = File(dict.txt)                .readLines()        dictionary                .filter { it.length == word.length }                .map { Pair(it, it.toCharArray().sorted()) }                .filter { it.second == sortedWordChar }                .forEach { print(${it.first} ) }        println()    }}
Anagram Generator
kotlin
    for (word in wordList) {        ...        val dictionary = File(dict.txt)                .readLines()        ...    }On the assumption that dict.txt isn't changing, I don't see a reason to keep this in the loop. Disk caching means that it might not have too bad a performance hit nowadays, but it's still not a good idea to do an expensive operation multiple times if you can store the result.                .map { Pair(it, it.toCharArray().sorted()) }                .filter { it.second == sortedWordChar }                .forEach { print(${it.first} ) }Since you don't need it.second past the filter, it would be simpler to write                 .filter { it.toCharArray().sorted() == sortedWordChar }                 .forEach { print(${it} ) }On style, I'm not sure what's going on with the indentation. In particular,        val sortedWordChar =                word                        .toCharArray()                        .sorted()looks weird to me. If it's necessary to split into multiple lines (which I'm not convinced of, given that essentially the same expression is on a single line in the map), wouldn't one tab be sufficient indentation rather than two?