private void insertLine(File file, HttpSample httpSample) throws IOException {
   RandomAccessFile randomAccessFile = null;
   try {
     randomAccessFile = new RandomAccessFile(file, "rw");
     randomAccessFile.skipBytes((int) (file.length() - "\n</httpSamples>".getBytes().length));
     randomAccessFile.write("\n".getBytes());
     randomAccessFile.write(httpSample.toXML().getBytes());
     randomAccessFile.write("\n".getBytes());
     randomAccessFile.write("</httpSamples>".getBytes());
   } finally {
     if (randomAccessFile != null) {
       randomAccessFile.close();
     }
   }
 }