OPEN(FIle=input, OLD, ERror=21) ! on error branch to label 21 (not shown) OPEN(FIle=output) DO i = 1, 1E300 ! "infinite" loop, exited on end-of-file error READ( FIle=input, ERror=22) buffer ! on error (end of file) branch to label 22 WRITE(FIle=output, ERror=23) buffer ! on error branch to label 23 (not shown) ENDDO 22 WRITE(FIle=output, CLoSe=1)