title: file_get_contents doesn't work if the URL is a line from a text file
body: <p>Hey I'm new to PHP so this may be an obvious mistake. At the moment I am trying to read a score for games from metacritic and display it to the user. Here is the code I use to do that:</p>
  
  <pre><code>$linkToGame= 'METACRITIC LINK';
  
  $opts = array('http' =&gt; array('header' =&gt; "User-Agent:MyAgent/1.0\r\n"));
  $context = stream_context_create($opts);
  $url = file_get_contents($linktoGame, FALSE, $context);
  
  $first_step = explode( '&lt;span itemprop="ratingValue"&gt;' , $url );
  $second_step = explode("&lt;/span&gt;" , $first_step[1] );
  
  echo $second_step[0];
  </code></pre>
  
  <p>This does exactly what it is meant to do which is output the game rating from the metacritic url. What I am trying to do now is have it use a link from a text file which contains a list of 115 metacritic links. </p>
  
  <p>I used this to read the text file. </p>
  
  <pre><code>$lines = file('metacriticlinks.txt');
  </code></pre>
  
  <p>and then switched <code>$linkToGame</code> to </p>
  
  <pre><code>$linkToGame = $lines[1];
  </code></pre>
  
  <p>However by doing this, I get the following error:</p>
  
  <blockquote>
    <p>"Warning:
    file_get_contents(<a href="http://www.metacritic.com/game/3ds/steamworld-heist" rel="nofollow">http://www.metacritic.com/game/3ds/steamworld-heist</a>
    ): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
    in C:\xampp\htdocs\learn\getwebcontent.php on line 19"</p>
  </blockquote>
  
  <p>The weird thing is if I replace <code>$linkToGame</code> with the exact URL it is displaying in the warning, the code runs perfectly and displays the score for that game. I tried reading each line into an array and using an item from an array but that didn't work either and produced the same warning. </p>
  
  <p>The oddest part of this issue is that if I use the last line in the text file or in the array (115), the code works as it should. It just doesn't work for any other line except for the final line. What could be the issue?</p>
  
  <p>Many thanks. </p>