Avoid using unopened files.

When many channels are selected for recording a race condition can cause a crash by writing to a file that has not been opened yet.