Your debugger is for this type of problem.
When you take sizeof(FileOut) you get the size of pointer FileOut which is 4 bytes.
Change this line to:
fwrite(FileOut, sizeof(BYTE), sizeof(BYTE) * ArraySize, file2);
[Edit]
There is a correction to the above. It should read:
fwrite(FileOut, sizeof(BYTE), ArraySize, file2);
It will then work correctly if FileOut is declared as int for example:
fwrite(FileOut, sizeof(int), ArraySize, file2);