Hi. I have just changed my while loop (an eof check) to a for loop.

Code:
for (j=0; j<size2; j++){

fIn2.read(xCh,4);
fout.write(xCh,4);
fIn2.seekg(12,ios_base::cur);
}
i have removed most of the functions in this loop for simplicity of posting, but basically what i am doing is reading in characters, rearranging them (shifting, etc), writing them out, and then skipping twelve characters to start the process over. size2 is the size of my file.

my problem is occurring because instead of ending when there is no data left to read in fIn2, it just keeps printing the last characters read in until the loop is over.

is there something i can add to my code to fix this problem? hopefully this was explained well-enough.