title: ifstream does not open a file in the next iteration
body: <p>I have two similar methods that open a file identically, but process them and return values a bit differently, yet while the first method does that successfully, the second method, which is called after the first one, fails.</p>
  
  <p>I have tried changing the path to this file, its extension, but I think I miss some important knowledge about ifstream.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>vector&lt;User&gt; Database::createUserDatabase()
  {   
      vector&lt;User&gt; users;
  
      ifstream inputFile;
      inputFile.open(pathToFile, ios::in);
  
      //Some file processing
  
      inputFile.close();
      return users;
  }
  </code></pre>
  
  <p>And that works perfectly, while</p>
  
  <pre class="lang-cpp prettyprint-override"><code>vector&lt;User&gt; Database::createBookDatabase()
  {   
      vector&lt;Book&gt; books;
  
      ifstream inputFile;
      inputFile.open(pathToFile, ios::in);
  
      //Some file processing
  
      inputFile.close();
      return books;
  }
  </code></pre>
  
  <p>fails to end whenever I check if the file has been opened or not using</p>
  
  <pre class="lang-cpp prettyprint-override"><code>inputFile.is_open()
  </code></pre>
  
  <p>These functions are defined in class files Database.cpp, User.cpp, Book.cpp, which are correctly linked to the main.cpp with the following content:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;string&gt;
  #include &lt;cstring&gt;
  #include &lt;sstream&gt;
  #include &lt;vector&gt;
  #include &lt;fstream&gt;
  
  #include "../lib/Book.h"
  #include "../lib/User.h"
  #include "../lib/Database.h"
  
  using namespace std;
  
  int main() 
  {
      Database userDatabase("../database/users.txt", "users");
      Database bookDatabase("../database/lmsdb.txt", "books");
  
      vector&lt;User&gt; users = userDatabase.createUserDatabase();
      vector&lt;Book&gt; books = bookDatabase.createBookDatabase();
  
      return 0;
  }
  </code></pre>
  
  <p>Here are my <a href="https://i.imgur.com/atxFi2l.png" rel="nofollow noreferrer">Project directories</a></p>
  
  <p>Using gdb debugger, I have confirmed that the file is not being opened at all. I assume that I did not close the files properly, but I have a little knowledge of C++ yet (been learning it for only a week or so).</p>
  
  <p>Looking forward to see what you can suggest reading/researching, yet I really would like to see a straightforward solution to this problem.</p>