There may be efficient solutions than this but here is the one which will help you.
Yes, there are more efficient solutions. Why do you think posting an overly complex and inefficient solution is a way to help someone? You're not really helping people by continually doing that. You're just misleading them.
If the OP can use a symbol instead of a parmfile, then Kolusu's use of a symbolic for STOPAFT is best. And if the OP needs to use a parmfile, this DFSORT/ICETOOL job is better than your solution. STOPAFT is more efficient than ENDREC.
I assumed the parmfile has a 2-digit value for the number of records (e.g. 05), but the job can be changed appropriately for more digits).
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//PARMFILE DD DSN=... seq file with nn for number of records
//IN DD *
//CTL2CNTL DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(PARMFILE) TO(CTL2CNTL) USING(CTL1)
COPY FROM(IN) TO(OUT) USING(CTL2)
//CTL1CNTL DD *
OUTREC BUILD=(C' OPTION STOPAFT=',1,2,80:X)