https://en.wikipedia.org/wiki/The_General_(1926_film)
Disney also did a version back in the late 1950’s with Fess Parker, it was actually pretty good. It was called The Great Locomotive Chase
https://www.youtube.com/watch?v=-SG_0Yo8MGk