      PROGRAM STAT
      IMPLICIT NONE
      
      REAL V, SUM, AVG
      INTEGER N
      
      OPEN (UNIT = 1, FILE = 'DATA', STATUS = 'OLD')
      OPEN (UNIT = 2, FILE = 'OUTPUT', STATUS = 'OLD')
      
      N = 0
      SUM = 0.0
      DO WHILE (1 .EQ. 1)
        READ (1, *, END = 1000), V
        WRITE (2, *) 'THE ', N, 'TH DATA IS ', V
        SUM = SUM + V
        N = N + 1
      ENDDO
      
1000  CONTINUE
      AVG = SUM / N
      WRITE (2, *) 'THE AVERAGE OF ', N, 'DATA IS', AVG
      
      END FILE (UNIT = 2)
      CLOSE (UNIT = 1)
      CLOSE (UNIT = 2)
      
      STOP
      END