Lazy tmp write logic.