Parents have been urged to talk to their children about the dangers of trespassing on the railway after two youngsters were spotted on the tracks in Fife.
ScotRail has posted the warning on social media following the incident involving two primary school-age children, which happened in the kingdom at some point on Tuesday afternoon.
It is understood a train driver reported the incident as happening “in the Fife area” but no further details about exactly where, or at what time, have been divulged.
The apparent near-miss has sparked renewed warnings about safety on the railway lines.
“Both are safe, but the outcome could have been far worse,” the ScotRail post added.
The news comes after Network Rail revealed more than a quarter of teenagers who took part in a recent survey confessed to behaving in a way that could endanger their lives on the railway.
One in 10 young people admitted to walking along the railway line, while the number of young people taking risks on the tracks has gone up by almost 80% in the last five years.
In the 12-month period up to August, seven people under the age of 18 have lost their lives and a further 48 people received life-changing injuries.
Allan Spence, head of public and passenger safety at Network Rail, said: “Hundreds of people each year unintentionally take on the railway and lose.
“This year we have already seen a record number of young people losing their life or being injured on the track.
“The railway is full of both obvious and hidden dangers. The electricity on the railway is always on and always dangerous.
“Trains can also travel up to 125 miles per hour, so even if a driver can see your child, they can’t stop in time and they can’t change direction.
“Parents, please help us keep your children safe by educating them about what they take on when they step on the track.”
The rail industry is also working together to roll out a new schools engagement programme, in which community engagement managers from across Network Rail, British Transport Police (BTP) and train operating companies will teach thousands of children about railway safety.
BTP officers will also be increasing patrols across the country.