The moving train hit the schoolboy, believed to be 17-years-old, with a “glancing” blow as he tried to run off the tracks.
Emergency services scrambled to the line at around 2pm on Wednesday.
But the impact proved to be too severe and Joseph was tragically pronounced dead at the scene.
Following speculation over the circumstances surrounding Joseph’s death, family friend Steven Manderson took to social media on Saturday to clarify what happened.
He wrote: “Following on from Wednesday’s news of the tragic death of the young boy on the railway line in Dunfermline.
“After police enquiries and CCTV footage, the police have confirmed to the family that it was in fact a tragic accident.
“This family are close friends. A loving family and the death of their son is absolutely devastating for them.
“It appears he has gone on to help/rescue an injured animal.
“The train hit him with a ‘glancing’ blow as he tried to get off the tracks. Unfortunately the impact was just too severe.”
He continued: “It’s important to the family and everyone that knows them that this is recognised for what it was, a tragic tragic accident resulting in the loss of life of a young man who had everything to live for.
Joseph’s auntie, Julie Smart, also took to Facebook to release a statement on behalf of her family.
She said: “On behalf of my sister, brother-in-law, niece, myself and all our family, I need to confirm that on Wednesday we lost our dearest Joseph in a tragic accident.
“We need to respectfully let everyone know that Joseph did not take his own life.
“We have seen the comments and want to put the record straight and don’t want this perceived as anything other than what it actually was.
“The situation is deeply upsetting and our whole world has been turned upside down. He was our special,amazing boy.
“To us he was a son, a twin brother, a nephew, a grandson and a cousin. We need time, space and respect to deal with our loss.”
The posts have been inundated with hundreds of messages from people sending their condolences.
Michelle Drummond wrote: “This is so tragic, I can’t even imagine how his poor family are feeling. What a beautiful soul their amazing son must have been to go and rescue an animal.”
Eleanor Martin said: “Heartbreaking and so sad, condolences to the family.”
Janet Wright commented: “This is so sad, heartbreaking for the family.”
Zoë Kasprzak wrote: “I’m absolutely devastated and heartbroken, Joe was such a great, happy, smiling, kind and caring guy. Sending you all so much love and big hugs.”
Joanne Burns added: “We are with you all every step of the way, sending all our love.
“It’s just heartbreaking. We’re here for you always. Joseph was the most kind and loving boy and will be forever with you.
“Thinking about you all every minute of every day.”
On Wednesday, ScotRail Tweeted about the incident, writing: “Sadly, a person has been hit by a train between Inverkeithing and Cowdenbeath the line is closed.
“While the emergency services attend, our services between Edinburgh and Glenrothes With Thornton to Dunfermline Town will be cancelled.
“They later confirmed: “The line’s now reopened and our services can resume.
“However, they will still be subject to delay, cancellation or revision as we focus on getting trains and crew back into position.”
Speaking today a spokesman for British Transport Police said: “British Transport Police were called to the line near Dunfermline at 2.07pm on Wednesday 3 November following reports of a casualty on the tracks.
“Paramedics also attended, however sadly a 17-year-old boy was pronounced dead at the scene.
“This incident is not being treated as suspicious and a file will be prepared for the Procurator Fiscal.”