      implicit none
      integer i,iline,n,Nfiles
      real*8 r
      character*100 line,filein,fileout
	  character*20 filenamein,filenameout
	  character*3 ext
	  write(6,*)'Number of files to coorrect:'
	  read(5,*) nfiles
	  write(6,*)'input filename extension'
	  read(5,*) filenamein,ext
	  write(6,*)'Output file'
	  read(5,*) filenameout
	  do i=1,Nfiles
	  
	  filenamein=adjustr(filenamein)	  
	  if (nfiles.eq.1) write(filein,"(a20,a1,a3)")filenamein,'.',ext
	  if (nfiles.ge.2.and.nfiles.le.9) 
     & write(filein,"(a20,i1,a1,a3)")filenamein,i,'.',ext
	  if (nfiles.ge.10.and.nfiles.le.99) 
     & write(filein,"(a20,i2,a1,a3)")filenamein,i,'.',ext

	  filein=trim(filein)
	  filein=adjustl(filein)

  	  filenameout=adjustr(filenameout)
	  if (nfiles.eq.1) write(fileout,"(a20,a1,a3)")filenameout,'.',ext
	  if (nfiles.ge.2.and.nfiles.le.9) 
     & write(fileout,"(a20,i1,a1,a3)")filenameout,i,'.',ext
	  if (nfiles.ge.10.and.nfiles.le.99) 
     & write(fileout,"(a20,i2,a1,a3)")filenameout,i,'.',ext
	 
	  fileout=trim(fileout)
	  fileout=adjustl(fileout)

	  write(6,"(a20,2x,a20)")filein,fileout
	  open(unit=1,file=filein)
	  open(unit=2,file=fileout)
	  do iline=1,1000000
	  read(1,"(a70)",end=100) line
	  write(2,"(a70)") line
	  end do
100   continue
      close(unit=1)
	  close(unit=2)
	  end do
	  stop
	  end program
	  
	  