How to read file with \n character in it?
<p>I read that you can read a file line by line in Node.js like this:</p>

<pre><code>var array = require("fs").readFileSync("file").toString().split("\n");
</code></pre>

<p>But, if the file has a <code>\n</code> character in it, it splits that too, so you don't get the file lines the right way.<br>
Is there a way I can read a file with <code>\n</code> characters and get the files lines correctly?</p>

<p>For example, how would I split this file?</p>

<pre><code>file
print "\n"
exec
</code></pre>

<p>When I run the above code, it results like this:</p>

<pre><code>[ 'file', 'print "\\n"', 'exec' ]
</code></pre>

<p>Fix?</p>