title: SED: First and last empty lines not removed
body: <p>I'm running the following but it's returning with empty lines at the top and bottom of the new file.</p>
  
  <p>How do I output to a new file without these empty lines?</p>
  
  <pre><code>input | sed -E '/^$/d' &gt; file.txt
  </code></pre>
  
  <p>The following has no effect either.</p>
  
  <pre><code>sed '1d'  
  sed '$d'
  </code></pre>
  
  <p>I'm unsure of where the expression has problems.</p>