write_shared_index(): use tempfile module