Major train accident averted in Punjab