changed fwrite a to w