Refactor file streaming.