Refactor file system IO. Make file data part of file instead of stream. Require file to be created before opening.