title: Check if a new line exists at end of file
body: <p>I created a simple method to append text to a file:</p>
  
  <pre><code>void writeFile(String fileName, String... values) {
      File file = new File(fileName);
      file.getParentFile().mkdirs();
      try(BufferedWriter bw = new BufferedWriter(new FileWriter(file, true))) {
          for (String value: values) {
              bw.write(value);
              bw.newLine();
          }
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>However, I am at a loss on how to check if a new line exists at the end of the file before writing to ensure that it is stored properly.</p>
  
  <p>Also, it would have to be scalable for when working with larger files.</p>