Schoolboy hit by train told teacher about suicidal thoughts