title: Reading in a text file to an array including spaces
body: <p>I have to read this text file which already exists. This code compiles and works but it only reads in one word per line.</p>
  
  <p>For example: my txt file looks like this: </p>
  
  <ul>
  <li>word1 word2 word3 word4</li>
  <li>word5 word6 word7</li>
  <li>word8 word9</li>
  </ul>
  
  <p>But it outputs on the screen:</p>
  
  <ul>
  <li>word1</li>
  <li>word2</li>
  <li>word3.. etc.</li>
  </ul>
  
  <p>How can I get it to read the txt file into the array including the spaces?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  
  using namespace std; 
  
  int main()
  {
      string friendConnections[9];
      string line;
      int loop = 0;
  
      ifstream networkFile("network.txt");
  
      if (networkFile.is_open())
      {
          while (!networkFile.eof())
          {
              istream&amp; getline (networkFile &gt;&gt; line);
              friendConnections[loop] = line;
              cout &lt;&lt; friendConnections[loop] &lt;&lt; endl;
              loop++;
          }
          networkFile.close();
      }
      else cout &lt;&lt; "Can't open file" &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>