ofstream object after an if condition not working
<p>I'm facing something strange with a C++ code I'm working on. It's about an "ofstream" object that I created in order to have the data I need in a file. </p>

<p>Anyways, I need to place this object, which I call output1 after an "if" condition. So, any data that passes the condition I want then in the file. </p>

<p>Now, if I put the usual "cout" after the condition: </p>

<pre><code>.
.
if (Check == 0) cout &lt;&lt; data1 &lt;&lt; " " &lt;&lt; data2 &lt;&lt; endl;
.
</code></pre>

<p>I'll get results printed on the screen. </p>

<p>But when I put my output1, </p>

<pre><code>if (Check == 0) output1 &lt;&lt; data1 &lt;&lt; " " &lt;&lt; data2 &lt;&lt; endl;
</code></pre>

<p>then nothing is written in the file! </p>

<p>I have checked that my output1 object works fine somewhere else in the code. But not here! And the complier didn't mention any error or lack of declaration.</p>

<p>Any ideas?</p>

<p>Note: I can't put the code here, or even the relevant parts as it is a very long code and is not meant to be public, so I don't have the right to copy it. </p>
