title: Scala foldLeft with a List
body: <p>I have the following code snippet:</p>
  
  <pre><code>import scala.io.Source
  object test extends App {
  
    val lineIterator = Source.fromFile("test1.txt").getLines()
  
  
    val fileContent = lineIterator.foldLeft(List[String]())((list, currentLine) =&gt; { 
      currentLine :: list
      list
      })
  
  
      fileContent foreach println
  
  }
  </code></pre>
  
  <p>Let's assume the <code>test1.txt</code> file is not empty and has some values in it.
  So my question about the <code>foldLeft</code> function is, why does this example here return an empty list, and when I remove the <code>list</code> at the end of the <code>foldLeft</code> function it works?
  Why is it returning an empty list under the value <code>fileContent</code>?</p>