Building and querying an immutable phone book
Your indentation needs cleaning up.

The compiler says:


$ scalac -deprecation phoneBook.scala 
phoneBook.scala:5: warning: overriding method main in trait App is deprecated: main should not be overridden



Following the example in the documentation, inside the App, you should just put your code in the object itself, without any main function.

Translating the three verbs into a numeric code is unnecessary obfuscation.  Trying to handle all three kinds of commands in the same doAction function is also cumbersome.

Converting the Iterator into a Stream is counterproductive, when you intend to process each line just once.  It just makes you have to (rawLines drop 1) explicitly.

You're starting with an empty phone book (cryptically named acc).  Then you want to have each command transform it and pass it along to the next command.  Instead of explicit recursion in the doAction function, you would be better off using a fold.

Instead of instantiating scala.collection.immutable.HashMap, you can just use a Map and let Scala do the right thing.

import scala.io.Source.fromInputStream

object phoneBook extends App {

  def add(phoneBook: Map[Int,String], number: Int, name: String) = {
    phoneBook + (number -&gt; name)
  }

  def del(phoneBook: Map[Int,String], number: Int) = {
    phoneBook - (number)
  }

  def find(phoneBook: Map[Int,String], number: Int) = {
    println(phoneBook.getOrElse(number, "not found"))
    phoneBook
  }

  lazy val lines = fromInputStream(System.in).getLines
  val nQueries = lines.next.toInt

  lines.take(nQueries).foldLeft(Map.empty[Int,String])((phoneBook, line) =&gt; {
    line.split(" ") match {
      case Array("add", number, name) =&gt; add(phoneBook, number.toInt, name)
      case Array("find", number)      =&gt; find(phoneBook, number.toInt)
      case Array("del", number)       =&gt; del(phoneBook, number.toInt)
    }
  })

}


Actually, there is no need to convert the phone numbers to integers, unless you want to ensure that they are indeed numeric.  In fact, in general, phone numbers should not be treated as integers, since they may contain many digits, or may have significant leading zeroes.