save before rewrite