Curl is a more robust way to download files. The function page for curl_exec() gives example usage. Pay particular attention to the note about CURLOPT_RETURNTRANSFER, I've found it to be useful in my scripts.