The Boxcar Children tells the story of four orphaned children: Henry, Jessie (or Jess), Violet, and Benny. In the original 1924 version of the tale, the children are orphaned in the first few pages; in the heavily revised and simplified 1942 revision, they have evidently been orphaned for some time.
When a baker and his wife learn that the children are orphans, they make plans the children object to. In the 1924 edition, they plan to send the children, who live in a house next door to the bakery, to live with their grandfather, but the children have been brought up to fear their grandfather, whom they have never met, because he did not approve of their parents' marriage. In the 1942 revision, the children are already homeless and wandering at the start of the story. The baker and his wife plan to take in the three elder children, who are big enough to be useful in the bakery, but to send little Benny to a Children's Home.
Finding an abandoned boxcar, the children start a new life of independence. Henry ends up working various odd jobs in a nearby town (Intervale in the 1924 edition; Silver City in later editions) for a young doctor (Dr. McAllister in the 1924 edition; Dr. Moore in later editions), in order to earn money for food and other materials they need. He also does gardening for the doctor's mother. The children's lives are pleasant and full of hard work until Violet becomes ill and they go to the doctor for assistance.
Unbeknownst to the children, by that time the doctor knows very well who they are and where they are living; indeed, he has been keeping a discreet eye on them for weeks. Their grandfather, who lives nearby, has been advertising in the papers, offering a reward for news of them, but the doctor hasn't wanted to spoil the children's fun by informing on them. When Violet becomes ill, however, he feels it is time to do so.
Their grandfather, a steel baron (James Henry Cordyce in the 1924 edition; James Henry Alden in the 1942 revision), comes at once to see them. The doctor suggests that he get to know them first before telling them who he is, so he is simply introduced to them as a friend of the doctor's. The children warm to his kindness and are surprised but delighted when they eventually learn that he is their much-feared grandfather. They go to live with him after all, and he has the boxcar transferred to his backyard for their enjoyment.

Question: How did the doctor know the grandfather?
Answer: He offered an award.
Alternative answer: He put an advertisement in the paper.