A steam locomotive is a relatively simple machine, and could theoretically remain in service indefinitely... if you have a few important items:
1. KNOWLEGE - on how work needed is to be done. Unfortunately, some skills have been virtualy lost already.
2. MONEY - some things are just more expensive to do than others. The great majority of existant engines have or will eventually fall victim to the problem of needed repairs being beyond the financial wherewithal of their owners.
3. The WILL - At some point you are going to have to renew parts that will significantly alter the historic fabric of the engine. Remember the old saw about George Washington's axe....
4. SUPPORT - All of the above are going to be useless if the @#$%&, Greenies, Insurance Companies, and/or Other Special Interests, manage to legislate your locomotive right out of viable existance.