The Rhymney line will be closed for two separate six-week stretches