close temp file before rename for #7