PRO Stack_writelist, list_filename, filename_list

IF (n_elements(filename_list) eq 0) THEN BEGIN
    print,'No files in list!'
    return
ENDIF

IF (n_elements(list_filename) EQ 0) THEN BEGIN
    print,'No filename to write list to!'
    return
ENDIF

get_lun,lun
on_ioerror,bailout

openw,lun,list_filename
for i=0,(n_elements(filename_list)-1) do begin
  printf,lun,filename_list(i)
endfor

bailout:
close,lun
free_lun,lun

return
END







