Actually it was more complicated than that. The labor costs on steam locomotives were raised to the point that railroads were forced to switch to diesel. A lot had to do with banks machinations. Coal might "look" dirty because the smoke is highly visible. But other fuels are just as toxic and they pose just as bad environmental problem. Just because we don't see the fumes, it doesn't mean they are not there. Digging for oil is exactly that, still digging for oil, if you take into account oil spills in the ocean, the end result is the same. This same problem is there when digging for lithium and other substances which make up batteries, all the same.