title: File "not declared in scope" even though it was
body: <p>Part of my program includes writing to a text file. I have:</p>
  
  <pre><code>#include&lt;fstream&gt;
  #include&lt;iostream&gt;
  #include&lt;string&gt;
  #include&lt;cstdlib&gt;
  #include&lt;ctime&gt;
  
  using namespace std;
  
  //I open the file "highscore.txt" here, read it, and then close it.
  
  ofstream outfile;
  
  outfile.open("highscore.txt", ios::out);
  
  outfile&lt;&lt;score;
  
  outfile.close();
  </code></pre>
  
  <p>I asked different people and it said it looks right, but when I try to compile it am getting the error:</p>
  
  <blockquote>
    <p>"outfile" was not declared in this scope</p>
  </blockquote>