Amniocentesis can also be used late in pregnancy to find out whether the fetus' lungs are ready for life outside the uterus. This is usually done if the fetus needs to be delivered before term.