title: sort -o appends newline to end of file - why?
body: <p>I'm working on a small text file with a list of words in it that I want to add a new word to, and then sort. The file doesn't have a newline at the end when I start, but does after the sort. Why? Can I avoid this behavior or is there a way to strip the newline back out?</p>
  <h2>Example:</h2>
  <p><code>words.txt</code> looks like</p>
  <pre><code>apple
  cookie
  salmon
  </code></pre>
  <p>I then run <code>printf &quot;\norange&quot; &gt;&gt; words.txt; sort words.txt -o words.txt</code></p>
  <p>I use printf rather than echo figuring that'll avoid the newline, but the file then reads</p>
  <pre><code>apple
  cookie
  orange
  salmon
  #newline here
  </code></pre>
  <p>If I just run <code>printf &quot;\norange&quot; &gt;&gt; words.txt</code> orange appears at the bottom of the file, with no newline, ie;</p>
  <pre><code>apple
  cookie
  salmon
  orange
  </code></pre>