title: Writing a string array to file using Java - separate lines
body: <p>I'm writing a program that writes sets of observations in the form of a String array (from User input) to file. I am able to write an observation to a .txt file and then add a new observation without removing the previous data, but all my data is on the same line. <strong>I need each set of observations to be on a separate line.</strong> Additionally I will need to be able to access the file later on and read from it.</p>
  
  <p>My code currently looks like this: (observation is the string array)</p>
  
  <pre><code>for(int i = 0; i &lt; observation.length; i++) {
      try (BufferedWriter bw = new BufferedWriter(new FileWriter("birdobservations.txt", true))) {
          String s;
          s = observation[i];
          bw.write(s);
          bw.flush();
      } catch(IOException ex) {}  
  }
  </code></pre>
  
  <p>My output currently looks like this: <code>CrowMOsloMay2015JayMOsloJune2012CrowMOsloMay2015RobinFBergenMay2012</code></p>
  
  <p>I would like it to look like this:</p>
  
  <pre><code>Crow M Oslo May2015
  
  Jay M Oslo June2012
  </code></pre>
  
  <p>...etc</p>
  
  <p>How do I do this? I assume I need some kind of loop, but I've been stuck on figuring this out for a while now. </p>