The last meter-gauge and narrow-gauge steam locomotives in regular service were retired in 2000. After being withdrawn from service, most steam locomotives were scrapped, though some have been preserved in various railway museums. The only steam locomotives remaining in regular service are on India's heritage lines.
Many locomotives can last 30–40 years, depending on the maintenance done on them. Our GG1 Lasted 41 years, but many of the steam locomotives were retired early. So they had years left in them, but the company did not want to run steam anymore, so they were retired early.
Coal fired steam locomotives do produce a lot of CO2 emissions but also aerosols which has a cooling effect (global dimming), which cancels out some of the warming produced by CO2. Diesel locos probably produce less CO2 but also less aerosols that would cancel out the CO2.