title: C++ Search TXT File return int
body: <p>The code bellow is from a larger one I'm working on. It searches for a username in a txt file. If the name is found, it returns ether a int 0 or int 1. It compiles and runs but no matter if the user is in the txt file or not, it always runs the shut down action making me think the function returns 0 every time. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  
  int DoThis(int UF);
  
  int main(void)
  {
      int z;
      z = DoThis(0);
  
      if(z == 1){RunThing;}
      else if(z == 0){ShutDown;}
  
  return 0;
  }
  
  int DoThis(int UF)
  {
  int offset;
  std::cin &gt;&gt; NameToCheck;
  Myfile.open("FilePath")
  
  if(Myfile.is_open())
      {
          while(!Myfile.eof())
          {
              getline(Myfile,line);
              if((offset = line.find(NameToCheck, 0)) != std::string::npos) 
              {
                  while(Myfile &gt;&gt; FirstName &gt;&gt; LastName)
                  {
                      return = 1;
                  }
              }
          }
      Myfile.close();
      }
      else
      {
          std::cout &lt;&lt; "File not found.";
      }
  return 0;
  }
  </code></pre>