title: Inserting text in middle using RandomAccessFile removes some text after that
body: <p>My Sample Code</p>
  
  <pre><code>    String line = null;
      RandomAccessFile file = new RandomAccessFile("D:/mahtew.txt", "rw");
      System.out.println(file.getFilePointer());
      while((line = file.readLine()) != null){
          System.out.println(line);
          System.out.println(file.getFilePointer());
  
          if(line.contains("Text to be appended with")){
              file.seek(file.getFilePointer());
              file.write(" new text has been appended".getBytes());
              break;
          }
      }
      file.close();
  </code></pre>
  
  <p>demo.txt before execution</p>
  
  <pre><code>one two three
  Text to be appended with
  five six seven
  eight nine ten
  </code></pre>
  
  <p>demo.txt after execution</p>
  
  <pre><code>one two three
  Text to be appended with
   new text has been appendedten
  </code></pre>
  
  <p>Also i tried using setLength to change length of file before new text is appended. But still some text is getting trimmed from output file. Any help will be appreciated</p>
  
  <p>Thanks
  Mathew</p>