A teenage driver has been sentenced for causing a crash which nearly killed a four-year-old who was waiting for a bus.