Moved file writing to commit.