Can tempfile.NamedTemporaryFile be used here?