it is entirely possible that what you are writing is causing the problem: you aren't writing a zero byte, you are writing a '0' character which is a very different value.
Try this instead:
file << (unsigned char) 0;
However, I do not think that the first byte of the file is a region code - it doesn't appear to be described as such in the container specification:
http://matroska.org/technical/specs/index.html[
^]