title: How to read text file into deque
body: <p>I am trying to construct a deque of strings (in C++) from a txt file by putting a new entry in the deque for each line in the file. Below is my attempt at the function - I know that the while loop is being executed the proper number of times, however after calling this function the queue is always empty. I'm sure I'm missing something small (very new to C++ syntax and workings...), and any help is greatly appreciated.</p>
  
  <pre><code>void read_file(string file_name, deque&lt;string&gt; str_queue) {
      ifstream filestr;
      filestr.open(file_name);
      if (!filestr.is_open()){
          perror ("Error opening file.");
      }
      else {
          while (filestr) {
              string s;
              getline(filestr,s);
              str_queue.push_back(s);
          }
      }
  }        
  </code></pre>