title: How to resolve "cannot resolve groupBy" error message?
body: <p>I'm a newhand in Scala, as the topic</p>
  
  <pre><code>package edu.luc.cs.cs372.echo
  package main
  
  object Main extends App {
    val lines = scala.io.Source.stdin.getLines
    val words = lines.flatMap(_.split("\\W+"))
    val list2 = words.groupBy(_.length).mapValues(_.length)
    val vectorOfLengths = (1 to list2.keys.max).map(length =&gt;list2.getOrElse(length, 0))
    for ((count, length) &lt;- vectorOfLengths.zipWithIndex)
      println(f"${length+1}: ${"#" * count}")
  </code></pre>
  
  <p>Errors are thrown here:</p>
  
  <pre><code>Error:(7, 21) value groupBy is not a member of Iterator[String]
    val list2 = words.groupBy(_.length).mapValues(_.length)
                      ^
  
  Error:(9, 43) Cannot construct a collection of type That with elements of type (A1, Int) based on a collection of type scala.collection.immutable.IndexedSeq[Nothing].
    for ((count, length) &lt;- vectorOfLengths.zipWithIndex)
                                            ^
  </code></pre>
  
  <p>How to resolve this problem?</p>