Man pulled from train tracks moments before train pulls in