I've been given a data file laid out as such: heading1 heading2 heading3 x1 y1 z1 x2 y2 z2 x3 y3 z3 .etc. where x=integer, y,z=real I need to count the number of lines to allocate x, y and z their sizes. My first attempt looked like: ... OPEN(21, FILE='data.dat', STATUS=OLD) counter=1 ok=.FALSE. DO WHILE (.NOT. ok) READ(21,'\,1X,I1') first counter=counter+1 IF (first .EQ. ' ') THEN numberoflines=counter-1 ok=.TRUE. ELSE CONTINUE END IF END DO ... This runs into the problem that i don't know what type to make "first" as it'll be looking at integers until the last line. If anyone can help it'd be much appreciated!