What makes you think India hasn't been investing in railway safety? While the recent accident was unfortunate, number of railway accidents have been decreasing over years. Here is an infographic:
https://cdn.statcdn.com/Infographic/images/normal/30152.jpeg