chaging to work with files instead of streams