An anonymous donor has given £200,000 towards the restoration of a famous locomotive that appeared in The Railway Children.