Windows sunucuda çalıştırıyorsanız fopen('dosya', 'w+a') şeklinde kullanın.
Ayrıca fwrite yazmaya gerek yok. CURLOPT_FILE o işi yapıyor zaten.
Örnek:
function downloadFile($link,$name=null)
{
$link_info = pathinfo($link); //Yol bilgilerini degiskene atiyoruz.
$uzanti = strtolower($link_info['extension']); //Dosyanin uzantisini degiskene atiyoruz.
$file = ($name) ? $name : $link_info['basename'];
//Eger kayit edilmek üzere dosya adi girilmisse, girilen dosya adini degiskene atiyouruz, girilmemisse orjinal adini degiskene atiyoruz.
$curl = curl_init();
$fopen = fopen($file,'w');
curl_setopt($curl, CURLOPT_URL, $link);
curl_setopt($curl, CURLOPT_HEADER,0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_TIMEOUT, 120);
curl_setopt($curl, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_0);
curl_setopt($curl, CURLOPT_FILE, $fopen);
curl_exec($curl);
curl_close($curl);
fclose($fopen);
}