Beginning Scala - error in Sum code example (missing arguments for method collect)

In the excellent book, Beginning Scala, there is an error in the an example named Sum that leads to an error message that begins, "missing arguments for method collect". Actually, this isn't an error, but it was a change in the Scala API after Scala 2.7.3, which is what the book was based on.

Here's a corrected version of the Sum class (Sum object, actually), courtesy of the URL shown, with two minor changes by me:

import scala.io._

/**
 * This is a corrected version of the Beginning Scala Sum class.
 * The book version of the class worked on Scala 2.7.3, but does not work
 * on newer versions of Scala (2.8, 2.9, etc.).
 */
object Sum {
  def main(args: Array[String]): Unit = {
    println("Enter numbers on separate lines and press ctrl-D (Unix/Mac) ctrl-C (Windows)")
    val input = Source.fromInputStream(System.in)
    val lines = input.getLines.toList
    println("Sum " + sum(lines))
    // note: you can use toSeq here as well
    //val lines = input.getLines.toSeq
  }

  def toInt(s: String): Option[Int] = {
    try {
      Some(Integer.parseInt(s))
    } catch {
        case e: NumberFormatException => None
    }
  }

  def sum(in: Seq[String]): Int = {
    val ints = in.flatMap(toInt(_))
    ints.foldLeft(0)((a, b) => a + b)
  }

}

In this corrected version, this line:

val lines = input.getLines.collect

has been changed to this line:

val lines = input.getLines.toList

As one of the notes on that web page shows, you can use this line as well:

val lines = input.getLines.toSeq

I tested both toList and toSeq with Scala 2.9.1, and both work fine, problem solved.