title: how to close stream associated w/ iterator returned by Source.fromFile("/tmp/foo").getLines()
body: <p>I need to create an iterator using Source.getLines(), and from a quick look at the 
  Scala source code, and after running some tests it seems like the iterator does not close
  even after the iterator is exhausted (i.e., after hasNext() begins to be false).</p>
  
  <p>I'm wondering what is Scala's recommended technique for closing/releasing resources used to create an iterator. I found 
  an interesting library that seems like it would do the trick:</p>
  
  <pre><code>https://github.com/jsuereth/scala-arm
  </code></pre>
  
  <p>However, I'd prefer to use core scala libraries instead of 
  pulling in 3rd party stuff if possible.   If you are interested 
  in how I tested this (on Linux using the 'lsof' to list open files), my 
  code is below:</p>
  
  <pre><code>        object Test extends App {
            import sys.process._
            import scala.io.Source._
  
  
            "echo hello world" #&gt; new java.io.File("/tmp/testing") !
  
            val  src = fromFile("/tmp/testing")
            val iter: Iterator[String] = src.getLines()
            while (iter.hasNext) {
              println("line=" + iter.next())
            }
  
            println("iterator exhausted.. sleeping while we check if file is still open using lsof")
            Thread.sleep(200000)
          }
  </code></pre>
  
  <p>After running the program and it is still sleeping, run this command: </p>
  
  <pre><code> lsof   | grep /tmp/testing
  </code></pre>
  
  <p>and you will probably see output like this:</p>
  
  <pre><code>java  15813 ...253,0.... 12 .. lots-of-othernumbers..0462 /tmp/testing
  </code></pre>
  
  <p>Then when the program terminates, the grep will come up empty (as you would think).  </p>
  
  <p>Thanks in advance for any tips you can provide !</p>