Correcting dxpy.upload_string calls to wait for the file to close