title: Count the number of executions of a program using a file
body: <p>I am trying to find the number of times the code has been executed using the code below. But it doesn't work.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;conio.h&gt;
  
  using namespace std;
  
  int main()
  { 
      fstream outputFile;
      outputFile.open("count.txt");
  
      int count;
      outputFile&gt;&gt;count;
      count = count + 1;
      cout&lt;&lt;count;
      outputFile &lt;&lt;count &lt;&lt; endl;
      outputFile.close();
      getch();
      return 0;
  }
  </code></pre>
  
  <p>What could be the issue?</p>