title: How to exit from .out file to add string to stdin?
body: <p>I'd like to add every line to stdin, but I can't because a.out doesn't exit from loop.</p>
  <p>C++ code:</p>
  <pre><code>#include &lt;iostream&gt;
  
  int main() {
    std::string in;
    
    while(1){
      std::cin &gt;&gt; in;
      if(in == &quot;exit&quot;)
        break;
      std::cout &lt;&lt;in &lt;&lt; &quot;\n&quot;; 
    }
    return 0;
  }
  </code></pre>
  <p>And a bash code:</p>
  <pre><code>#!/bin/bash
  while read -r line
  do
    echo &quot;$line&quot; | ./a.out &gt;&gt; output.txt
  done &lt; &quot;input.txt
  </code></pre>
  <p>Thanks!</p>