title: c++ txt file not created by .open
body: <pre><code>#include&lt;conio.h&gt;
  #include&lt;iomanip&gt;
  #include&lt;cmath&gt;
  #include&lt;iostream&gt;
  #include&lt;fstream&gt;
  #include&lt;string&gt;
  using namespace std;    
  int main()
  {
      fstream afile;
      afile.open("example.txt");
      afile&lt;&lt;"Hi I am Unnat";
      afile.close();
      string line;
      ifstream myfile ("example.txt");
      if (myfile.is_open())
      {
          while ( getline (myfile,line) )
          {
               cout &lt;&lt; line &lt;&lt; '\n';
          }
          myfile.close();
      }
      else cout &lt;&lt; "Unable to open file"; 
      return 0;
  }
  </code></pre>
  
  <p>The output i get here is always Unable to open file and when i check the folders I dont find example.txt
  Please help.</p>