A 199-year-old building that helped launch the age of railways has been saved from decay thanks to community fundraising and a major donation from Hitachi Rail.