title: Shell append redirection replaces existing text?
body: <p>For our school assignment, we have to implement input/output redirection. I managed to get the input and output redirection work, but I am facing an issue with append redirection. </p>
  
  <p>I am using testfile.txt:</p>
  
  <pre><code>test line 1
  test line 2
  </code></pre>
  
  <p>When the user types ls >> testfile.txt, I expect the output from ls to be added to the testfile. At this moment, the test lines get replaced by the output of the ls program.</p>
  
  <p>The rights that I am using to open the files are the following:</p>
  
  <pre><code>    file = open(redirect.getNewFile().c_str(), O_WRONLY | O_TRUNC, S_IRWXU);
  </code></pre>
  
  <p>Does anyone have an idea where it goes wrong?</p>
  
  <p>Thanks in forward.</p>