Refactoring - writing to the file is new method