A steam railway has been fined £40,000 after it allowed a three-year-old boy to walk into a carriage toilet without a floor.

Young Jay Lloyd was left hanging above the wheels of the moving carriage with his head only ten inches above the floor level before he was rescued by his mother, a court heard.

The toilet door should have been screwed shut after the floor had been removed to repair the brakes, but Jay managed to open it on his own while the South Devon Railway Trust train was travelling between Staverton and Buckfastleigh last June, magistrates were told.

"His mother managed to pull her son up. He was covered in oily marks but mercifully uninjured," said Chloe Barton for the Government’s Office of Rail and Road which had brought the prosecution against the Totnes Buckfastleigh rail line.

But, she said, the result of the rail line’s actions could have been "catastrophic" as she told magistrates: "The risk could have resulted in serious injury or death."

The South Devon Railway Trust was also ordered to pay £13,205 in court costs and a £170 victim surcharge after it admitted an offence under the Health and Safety at Work Act.

The company has been ordered to come up with £15,000 of the fine within a month and the rest in the next four years.

Barrister Ian Dixey appeared before magistrates at Newton Abbot Court on behalf of the rail charity where he entered a plea of guilty to the charge of failing in its duty to ensure people in its employment and passengers on coach W4805 were not exposed to risks to their safety.

After the hearing assistant chief of inspectors for heritage rail Ian Skinner said: "This sends out a powerful message to South Devon Railway Trust and other heritage lines that they need to understand the risks they are trying to control."

A spokesman for the rail line said the charity had acknowledge its "shortcomings and accepted that it had put customers at risk.

He added: "The South Devon Railway takes the safety of its customers and staff very seriously and has put every effort into making improvements to its systems, including a new Safety Management System, to ensure that this incident could not happen again."

He added: "The South Devon railway accepts and regrets that improvement was needed at the time of the incident. Hopefully it can been seen that the trust has reacted appropriately and seriously in the circumstances."

He also pointed out that while the level of fine will have a "significant impact" on heritage rail charity’s finances it had put "contingencies" in place in preparation for the court hearing.

"We will continue to be running trains," he said.

The South Devon Rail Trust covering the six miles of rail line between Totnes and Buckfastleigh was formed in 1974.

It currently has 32 full time and 24 part time staff along with 500 volunteers with a turn over of almost £3 million a year, magistrates heard.

Jay and his mother Anna from near Ottery St Mary were having a day out on the rail line on June 22 last year and were travelling back to Buckfastleigh when the youngster said he needed to use the toilet, Ms Barton explained.

"Before she could tell her son that the toilet was not in use he had opened the door and gone in," she said. "He shouted. His mother saw there was no floor and her son had fallen through the hole."

She said the train was moving at about 20mph at the time.

Jay’s mother managed to pull the boy up by his arms before reporting the incident to the guard.

"He head was about ten inches above the floor he had fallen through. His mother was able pull him up after grabbing him by the arms and he escaped without injury," said Ms Barton.

She said that the carriage, dating back to the 50s and 60s had had the toilet floor removed in March to get at the brakes below because the rail line did not then have the capacity to lift the carriage off the wheels.

When it was realised that the cubicle was in a corroded state it was decided to lock it up until a full repair could be carried out - which could not take place for another four and a half weeks.

Then, faced with a "desperate shortage of rolling stock" the carriage was then put back into service for the rail line Diesel Gala with the door screwed shut with two screws, tape across the door and a sign saying not in use, explained Ms Barton.

It then remained in service until June 25 - three days after the incident involving Anna and Jay.

Ms Barton said that one explanation for Jay being able to open the door was that without the floor the carriage was abled to "flex" more than usual and that had broken the screws and the door jam.

She said that the subsequent investigation had shown that the rail line’s Safety Management System was out of date and "not fit for purpose" which has since been remedied.

Mr Dixey said that because of the shortage of rolling stock the carriage had been allowed back inservice after the toilet floor had been removed.

"The decision was made that as long as the toilet was isolated it was perfectly safe to continue to use the carriage," he told magistrates.

He stressed that it had not been done to avoid carrying out repairs and he said the company accepted that its safety management system was out of date.

He pointed out that the company had a "blameless" health and safety record since 1974 and said that if the toilet door had been insecure for any length of time it would have been noticed by a member of the public and reported.

"The failure must have been something that had happened recently," he said.

"There was never any intention not to carry out the repair, it was only a question of when it should have been done and what happened to the carriage in the meantime," he said.

He told magistrates that the rail operation was "not a profitable company" and that any financial penalty would have a "significant effect on the running of the company".

He added: "This is a decent company run by some sincerely decent and committed people and does a lot of good educational charity works."