node.js read a text file and write modify strings. (each line has a word order)
<p>I would like to read a large file from a thousand lines. Each line has the words and phrases.</p>

<p>So if the file is like this:</p>

<pre><code>key, phrase, combination of words, phrase, combination of keys, word
phrase, word
key, words, phrase, combination of keys, combination of words
combination of keys
words, phrase, combination of keys
</code></pre>

<p>In line combination or single words separated by commas</p>

<pre><code>.split(",")
</code></pre>

<ol>
<li>How to write to file the combination of the first four words or less in string?</li>
<li>How not to write to file strings without commas?</li>
</ol>

<p>Desired result modify:</p>

<pre><code>key, phrase, combination of words, phrase
phrase, word
key, words, phrase, combination of keys
words, phrase, combination of keys
</code></pre>