The read from stdin and from the word list file could be wrapped in an async generator to avoid having to load the whole file into memory at once. This would require manually extracting the newline-delimited words and then yielding them from the generator.
This would reduce memory usage, but would not completely avoid loading the words into memory as we have to do that to collect the anagram groups.