I believe this was a made for tv movie that i watched probably in the late seventies or early eighties. It was western themed, similar to Grizzly Adams, with a similar story line. The man was forced to leave his wife’s (or girlfriend’s) ranch for a crime he was framed for by some other dudes. The man escapes into the mountains. Somehow there is a contest or something which is supposed to be impossible to win. The contest entails finding a lost train steam locomotive which was buried on the mountain and bring it back to town. The man finds the locomotive and digs it out by diverting a stream and then tows it down the mountain with a horse and sled. He wins the contest and his freedom.
“Something for a Lonely Man” (1968 TV movie)
https://www.imdb.com/title/tt0063625/
https://en.wikipedia.org/wiki/Something_for_a_Lonely_Man
“Something for a Lonely Man” (1968 TV movie)
https://www.imdb.com/title/tt0063625/
Detailed plot:
https://en.wikipedia.org/wiki/Something_for_a_Lonely_Man