title: Why is the stream being closed when using Scala Using
body: <p>I am writing some tests for a function which loads a CSV via a function <code>readIntoList</code> using a BufferSource.</p>
  <pre class="lang-scala prettyprint-override"><code>
  class CSV(source: BufferedSource) {
  
    def readIntoList: List[List[Any]] = {
      lazy val lines = Using.resource(source) { x =&gt; x.getLines.zipWithIndex }
      println(source)
      val columns = for {
        (line, index: Int) &lt;- lines
      } yield {
        val cols = line.split(&quot;,&quot;).map(_.trim)
        val row = cols(0)
        if (index == 0) List(&quot;Index&quot;, row)
        else List(index, row)
      }
      columns.toList
    }
  }
  </code></pre>
  <p>Loading the source with a string works fine.</p>
  <pre><code>val singleRowCSV =
            &quot;&quot;&quot;TotalSpend
              |111
              |&quot;&quot;&quot;.stripMargin
  val csv = new CSV(
      new BufferedSource(new ByteArrayInputStream(singleRowCSV.getBytes()))
  )
  </code></pre>
  <p>However calling the function using <code>Source.fromURL</code> and providing a CSV on the file system.</p>
  <pre><code>val resource = getClass.getResource(&quot;/10_rows.csv&quot;)
  val csv = new CSV(Source.fromURL(resource))
  </code></pre>
  <p>Causes <code>java.io.IOException: Stream closed</code></p>
  <p>It was my understanding that Using will automatically close the stream for me, so now I am wondering where the stream is being closed?</p>