It was happen for ‘end of file indicator’. That means after writing file, something write in last file for a time. I just add a condition in
if (curImg) fwrite(buffer, sizeof(buffer), 1, curImg);
if (curImg && !feof(file)) fwrite(buffer, sizeof(buffer), 1, curImg);
CLICK HERE to find out more related problems solutions.