>>33
>   if(NULL != (fp = fopen(file, "wb"))) {

freopen()しろ、この呆けが!