Nephrostomy is done to prevent a kidney from being damaged due to urine build-up.