Ciao,
hai provato ad impostare la lunghezza del testo che stai per scrivere?

int fwrite ( resource handle, string string [, int length] )