<Example Program>

Program open_example
   
Open (1,File='DAT',Status='old',Position='Rewind')
    n_lines = 0
    Do
        Read (1,'( )',End=10)
        n_lines = n_lines + 1
    End Do
10 Continue
    Print *,'There are',n_lines,'lines in the file'
   
Close(1)
End


Contents of file: DAT

This is line 1
This is line 2
This is line 3; it is longer than the other lines

Execution Results

  There are 3 lines in the file