title: Output to file c++
body: <p>very simple program, not sure why it isn't working:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;stdio.h&gt;
  
  using namespace std;
  
  int main ()
  
  {
  ofstream myfile ("test.txt");
  if (myfile.is_open()) 
  {
      for(  int i = 1;  i &lt; 65535;  i++  )
  
       {
       myfile &lt;&lt; ( "&lt;connection&gt; remote 208.211.39.160 %d udp &lt;/connection&gt;\n", i );
       }
      myfile.close();
  }
    return 0;
  }
  </code></pre>
  
  <p>Basically it should print that sentence 65535 times, and then save it to a txt file. But the txt file just has a list of numbers from 1 to 65535, no words or formatting. Any ideas? Thanks for help.</p>