A train driver who crashed into a station and caused £450,000 of damage was using his phone seconds before the smash.
Phillip Hollis, 56, who has admitted endangering the safety of passengers, was travelling at 40mph - almost three times the 15mph speed limit - when he smashed into Kirkby station, in Merseyside.
He applied the emergency brakes but the train collided with the buffer stop at the end of the platform and derailed.
Twelve passengers and a guard who was on board the service escaped with only minor injuries.
Hollis later told police he was trying to retrieve his bag and a bottle of Lucozade which had fallen off a cupboard in the cab, before sitting back down and seeing the buffer at the last minute.
But detectives discovered he sent a WhatsApp message just 26 seconds before the accident.
And police said it was "sheer luck" no one died.
A BTP spokesman said: “Hollis told police that his bag had fallen off a cupboard in the cab and he’d stood up to retrieve it along with a bottle of Lucozade, before sitting back down and seeing the buffers approaching
“However, when Hollis’s phone was seized and analysed, detectives found he’d sent a WhatsApp message at 6.51.34pm, 26 seconds before the crash.
“He was interviewed again by detectives and admitted his phone should have been turned off in the cab.”
Hollis, from Liverpool, was sacked by Merseyrail after the crash at Kirkby station last March.
He admitted endangering the safety of passengers at Liverpool magistrates’ court last Monday and will be sentenced at a later date.
Detective Chief Inspector Steve May said: "This was a complex investigation but we could be confident from our analysis that Hollis was using his phone in the seconds before crashing the train into Kirby station at high speed.
"I have no doubt this will have caused him to become distracted while driving, endangering the safety of the passengers and staff on board.
"It was only through sheer luck that they weren't seriously injured or worse, killed, as a result of this incredibly dangerous incident."