title: C++ Making a function for reading in a .txt file and checking to make sure the file exists, but my loop isn't working
body: <p>I'm trying to make a function to read in a file, check to make sure it exists (and if it doesn't ask for the filename again), and then print "Loading..." if it DOES find the file.</p>
  
  <p>However, the loop only goes through once. It prints out "FILE ERROR: File does not exist!" and then ends the program. Any ideas? Tell me if you need more information!</p>
  
  <pre><code>void find_board(string fileName)
  {
  bool filefound = 0;
  ifstream in_stream;
  
  do
  {
      cout &lt;&lt; "Enter the name of the file containing the board: ";
      cin &gt;&gt; fileName;
  
      in_stream.open(fileName.c_str());
  
      if (in_stream.fail())
      {
          filefound = 0;
          cout &lt;&lt; "FILE ERROR: File does not exist!" &lt;&lt; endl;
          exit (EXIT_FAILURE);
      }
      else
      {
          filefound = 1;
      }
  } while (filefound == 0);
  
  cout &lt;&lt; endl &lt;&lt; "Loading..." &lt;&lt; endl;
  
  return;
  }
  </code></pre>