program one2n_write_file_2 write(*,*)'what is N for 1+2+...N' read(*,*) n open(unit=10,file='mid.txt') m = 0 do i=1,n m=m+i write(10,*) m end do write(*,*)'The final result is',m write(*,*)'Intermidiate results are in mid.txt.' end