Partial refactoring of file editing.