Small refactor filewriter and work