title: Writing data generated in scala to a text file
body: <p>I was hoping somebody could help, I'm new to scala and I'm having some issues writing my output to a text file. </p>
  
  <p>I have a data table and I've written some code to read it in one line at a time, do what I want it to do, and now I need it to write that line to a text file.</p>
  
  <p>So for example, I have the following table of data type</p>
  
  <p>Name, Date, goX, goY, stopX, stopY</p>
  
  <p>1, 12/01/01, 1166, 2299, 3300, 4477</p>
  
  <p>My code, takes the first characters of goX and goY and creates a new number, in this instance 1.2 and does the same for stopX and stopY so in this case you get 3.4</p>
  
  <p>What I want to get in the text file is essentially the following:</p>
  
  <p>go, stop</p>
  
  <p>1.2, 3.4</p>
  
  <p>and I want it to go through hundreds of lines doing this until I have a long list of on and off in the text file.</p>
  
  <p>My current code is as follows, this is almost certainly not the most elegant solution but it is my first ever scala/java code:</p>
  
  <pre><code>import scala.io.Source
  
  object FT2 extends App {
  for(line&lt;-Source.fromFile("C://Users//Data.csv").getLines){
  
  var array = line.split(",")
  val gox = (array(2));
  val xStringGo = gox.toString
  val goX =xStringGo.dropRight(1|2)
  val goy = (array(3));
  val yStringGo = goy.toString
  val goY = yStringGo.dropRight(1|2)
  val goXY = goX+"."+goY
  
  val stopx = (array(4));
  val xStringStop = stopx.toString
  val stopX =xStringStop.dropRight(1|2)
  val stopy = (array(3));
  val yStringStop = stopy.toString
  val stopY = yStringStop.dropRight(1|2)
  val stopXY = stopX+"."+stopY
  
  val GoStop = List(goXY,stopXY)
  //This is where I want to print GoStop to a text file
  }
  </code></pre>
  
  <p>Any help is much appreciated!</p>