Refactor file rewriter