title: Why do I get a java.nio.BufferUnderflowException in this Scala
body: <p>I was trying to do some <a href="http://www.codecommit.com/blog/scala/scala-as-a-scripting-language" rel="nofollow noreferrer">scripting in Scala</a>, to process some log files:</p>
  
  <pre><code>scala&gt; import io.Source
  import io.Source
  
  scala&gt; import java.io.File
  import java.io.File
  
  scala&gt; val f = new File(".")
  f: java.io.File = .
  
  scala&gt; for (l &lt;- f.listFiles) {
   |   val src = Source.fromFile(l).getLines
   |   println( (0 /: src) { (i, line) =&gt; i + 1 } )
   | }
  3658
  java.nio.BufferUnderflowException
          at java.nio.Buffer.nextGetIndex(Unknown Source)
          at java.nio.HeapCharBuffer.get(Unknown Source)
          at scala.io.BufferedSource$$anon$2.next(BufferedSource.scala:86)
          at scala.io.BufferedSource$$anon$2.next(BufferedSource.scala:74)
          at scala.io.Source$$anon$6.next(Source.scala:307)
          at scala.io.Source$$anon$6.next(Source.scala:301)
          at scala.Iterator$cla...
  </code></pre>
  
  <p>Why do I get this <code>java.nio.BufferUnderflowException</code>?</p>
  
  <p><em>NOTE - I'm processing 10 log files, each about 1MB in size</em></p>