The problem I had was not only related to the first and last line. It seems that my PHP.ini file wouldn't allow external url for "file_get_contents". The script returned NULL as value. The solution was to use cURL instead, like this:
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$str = file_get_contents_curl('https://..../getLiveSchedule.json');
Then I could remove the first 17 and the last 5 characters to make the file "JSON friendly":
$validJSON = substr($str, 17, -5);
The output is now valid JSON code.