	subroutine keep_record(irec,buffer,length)

	byte rec_modified(64000)
	common /record/ rec_modified
	integer*2 irec_modified

	byte buffer(length)
	
	logical called
	common /calls/ called

	logical quit,exit,confirm,edited

	common /eflags/ quit,exit,confirm,edited

	if (.not. called) then
		open(unit=9,type='new',err=9000,
     1			name='fdmpwork1',form='unformatted')
		edited=.true.
	 endif

	if (rec_modified(irec).ge.127) then
		type 10,irec
 10		format(' Too many edits made to record ',i4/
     1		       ' Changes made this edit ignored'/)
		return
	 endif

	rec_modified(irec)=rec_modified(irec)+1
!
! had to change to reference i*2 for sorting
!
	irec_modified=rec_modified(irec)

	write(9) irec,irec_modified,buffer
	called=.true.

	return

9000	stop 'unable to open journal file'

	end
