title: Nodejs remove top lines of file if longer than a certian length
body: <blockquote>
  <p><strong>Note</strong>: there are various similar-looking questions to this, but they aren't for nodejs. Please don't mark this question as a duplicate unless it is a duplicate of a question tagged <a href="/questions/tagged/nodejs" class="post-tag" title="show questions tagged &#39;nodejs&#39;" rel="tag">nodejs</a>.</p>
  <p><strong>Note</strong>: <a href="https://stackoverflow.com/questions/38843016">this question</a> does not answer my question, it explains how to remove x lines from a file, but not to keep x lines from a file. That question does not explain how to get the line length of a file and use that to trim some lines. I answered this question because I found an answer. That answer should clear things up.</p>
  </blockquote>
  <p>In my application, a log file has many lines of logs written to it during normal usage. To save disc space, I would like to remove the first lines of a log file when it is longer than a set amount.</p>
  <p>For instance, if the maximum line length is 5 (just for example, not really what I want), then:</p>
  <pre><code>Line 1
  Line 2
  Line 3
  Line 4
  Line 5
  Line 6
  </code></pre>
  <p>Would get converted to:</p>
  <pre><code>Line 2
  Line 3
  Line 4
  Line 5
  Line 6
  </code></pre>
  <p>And</p>
  <pre><code>Line 1
  Line 2
  Line 3
  Line 4
  Line 5
  Line 6
  Line 7
  </code></pre>
  <p>Would get converted to:</p>
  <pre><code>Line 3
  Line 4
  Line 5
  Line 6
  Line 7
  </code></pre>
  <p><strong>Note</strong>: this question is tagged <a href="/questions/tagged/nodejs" class="post-tag" title="show questions tagged &#39;nodejs&#39;" rel="tag">nodejs</a>, so I would like an answer in nodejs without any libraries / dependencies (native fs is fine)</p>