Fix swap function to avoid prompt about overwriting temp file