title: Edit text file USing CasperJs
body: <p>Is it possible to read a text file and replace a character or strings and save it in a new file using CasperJs? I tried searching a lot but I can only find reading and writing data in text files...</p>
  
  <hr>
  
  <p>My main aim is to fetch some text and store it in json file, but the problem is I am getting <code>\n</code> with the text.</p>
  
  <p>I can fetch the text and store it in a json file, but to remove that <code>\n</code> character, I thought of opening that file and replace <code>"\n"</code> with <code>null</code>.</p>
  
  <p><strong>text to be fetched</strong>:</p>
  
  <pre><code>hello
  abc
  </code></pre>
  
  <p>I am using these commands:</p>
  
  <pre><code>var a = this.fetchText({type: 'xpath', path: 'tr5'});
  this.echo(JSON.stringify(a));   
  </code></pre>
  
  <p><strong>Output</strong>:</p>
  
  <pre><code>hello\n
  abc
  </code></pre>
  
  <p>and I don't want this <code>\n</code> character. I want to print <code>"hello"</code> and <code>"abc"</code> in same line.</p>
  
  <p><strong>Expected:</strong></p>
  
  <pre><code>hello abc
  </code></pre>
  
  <p>Please help me with the code.</p>