How do you synchronize access to the buffer?
Do you close the file after write, or are you waiting for access to the file?