	pro add_eof,Filename
;+
; NAME:
;	ADD_EOF
;
; PURPOSE:
;	ADD_EOF writes the END OF FILE marker ('1A'XB) into the given file.
;
; CALLING SEQUENCE:
;	ADD_EOF, [FileName]
;
; OPTIONAL INPUT:
;	Filename:  The name of the file to be processed of (string type). 
;	If no Filename is specified, then thr function PICKFILE is called.
;
;
; OUTPUT:     None.
;
; SIDE EFFECT: The file is overwritten.
;
; RESTRICTIONS: None.
;
; REVISION HISTORY:
;	Written by V.Grechnev, ISTP. 1994.
;-




if n_params() le 0 then Filename=pickfile()
if Filename eq '' then goto,exit

openr,lun,Filename,/get_lun
a=fstat(lun)

data=bytarr(a.size)

readu,lun,data
free_lun,lun

j=a.size

repeat j=j-1 until (j eq 0) or $
	((data(j) ne '0A'xb) and $
	 (data(j) ne '0D'xb) and $
	 (data(j) ne '1A'xb) and $
	 (data(j) ne '20'xb))


openw,lun,Filename,/get_lun
writeu,lun,data(0L:j),'1A'xb
free_lun,lun
flush,lun

print,'OK.'

exit:
end