Refactor FileWriter