write to a file
<p>I want to write to a file named "TEXT" and append to the file every time I run the program. It compiles but it does not take input. Please help out; I am new to programming.</p>

<p>Here's the code I'm working with:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;

main ()
{
    string line;
    ifstream file;
    file.open("TEXT",ios::in |ios::app);

    if (file.is_open())
    {
        while (file.good() )
        {
            getline (file,line);
            cout &lt;&lt; line &lt;&lt; endl;
        }
        file.close();
    } else
        cout &lt;&lt; "Unable to open file";
}
</code></pre>
