title: How to keep newline characters when I import a javascript file with FileReader?
body: <p>I'd like to know how I can retrieve the contents of a file keeping special characters with FileReader object.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form enctype="multipart/form-data"&gt;
      &lt;input type="file" id="file" name="file"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <pre class="lang-js prettyprint-override"><code>&lt;script&gt;
      $('#file').change(function () {
          var file = document.getElementById('file').files[0];
  
          var reader = new FileReader();
  
          reader.onload = function (event) {
              var file_content = event.target.result;
              console.log(file_content);
          }
  
          reader.readAsBinaryString(file);
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>this code print </p>
  
  <pre><code>"line1line2"
  </code></pre>
  
  <p>except my file content is </p>
  
  <pre><code>line1
  line2
  </code></pre>
  
  <p>How can I get ?</p>
  
  <pre><code>line1\nline2
  </code></pre>
  
  <p>I tried readAsBinaryString and readAsText methods without any success. Am I doing something wrong ?
  Thank you</p>
  
  <p><a href="https://developer.mozilla.org/en-US/docs/Web/API/FileReader" rel="nofollow noreferrer">FileReader doc</a></p>
  
  <p><strong>edit:</strong></p>
  
  <p>an example on JSfiddle <a href="http://jsfiddle.net/yTgp7/" rel="nofollow noreferrer">http://jsfiddle.net/yTgp7/</a></p>
  
  <p><img src="https://i.stack.imgur.com/xJm0F.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/Qa1YW.png" alt="enter image description here"></p>
  
  <p>The problem exists only on Firefox on mac Os X</p>