title: Scala file writing with Java printwriter - why does the file writer stop in this code?
body: <p>I'm working on a scala test case and using printwriter to populate some data.
  This doesn't make any sense so me - it looks like the appender just stops 3/4 of the way.</p>
  
  <p>You shouldn't need the code for the word count as you can see the last line in the file is incomplete:</p>
  
  <pre><code>hello world duck duck sauce sauce mazing ninjakeyboard skills ninja
  hello world duck duck sauce
  </code></pre>
  
  <p>Log: </p>
  
  <pre><code>[info] Give a file with 10 words repeated on 1000 lines and file handler 
  [info] - should give us an array of 10000 words *** FAILED ***
  [info]   8434 did not equal 10000 (WordCountFileHandler.scala:20)
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>import java.io.PrintWriter
  import org.scalatest.FlatSpec
  import org.scalatest.matchers.ShouldMatchers
  import WordCountFileHandler.WordCountFileHandler
  
  class WordCountFileHandler extends FlatSpec with ShouldMatchers {
  
    "Give a file with 10 words repeated on 1000 lines and file handler" should "give us an array of 10000 words" in {
      val filename = java.util.UUID.randomUUID().toString
      val testFile = new PrintWriter( filename , "UTF-8")
      for (x &lt;- 1 to 1000) yield {testFile.println("hello world duck duck sauce sauce mazing ninjakeyboard skills ninja")}
      testFile.close()
  
  
      val testOutput = WordCountFileHandler (filename)
      testOutput.size should equal(1)
      //testOutput.head.foreach(println(_))
      testOutput.head.size should equal (10000)
    }
  }
  </code></pre>