However, one question comes to my mind. Shared file stream fixes the problem when file handle is destroyed at the end of each segment and new one is created at the beginning of next segment. But now it needs locking critical section for each read/write to ensure that changing file position and file operations are atomic. Now the question - doesn't such critical section bring more overhead than separate file handles?