writer runs before_write hook