title: No new line produced by >>
body: <p>I have the following piece of code that selects two line numbers in a file, extracts everything between these lines, replaces the new line characters with tabs and places them in an output file. I want all lines extracted within one loop to be on the same line, but lines extracted on different loops to go on a new line. </p>
  
  <pre><code>for ((i=1; i&lt;=numTimePoints; i++)); do  
      # Get the starting point for line extraction. This is just an integer.
      startScan=$(($(echo "${dataStart}" | sed -n ${i}p)+1))  
      # Get the end point for line extraction. This is just an integer.          
      endScan=$(($(echo "${dataEnd}" | sed -n ${i}p)-1)) 
      # From file ${file}, take all lines between ${startScan} and ${endScan}. Replace new lines with tabs and output to file ${tmpOutputFile}    
      head -n ${endScan} ${file} | tail -n $((${endScan}-${startScan}+1)) | tr "\n" "\t" &gt;&gt; ${tmpOutputFile}   
  done
  </code></pre>
  
  <p>This script works mostly as intended, however all new lines are appended to the previous line, rather than placed on new lines (as I thought <code>&gt;&gt;</code> would do). In other words, if I were to now do <code>cat ${tmpOutputFile} | wc</code> then it returns <code>0 12290400 181970555</code>. Can anyone point out what I'm doing wrong? </p>