A driver has been jailed after crashing into the back of a car while gambling on his mobile phone, and causing a pregnant woman to go into labour.