PRO wait4file,file ;wtime=0.1 wtime=1. message,'Waiting for file: '+file,/info ;will wait until the specified file exist and is finished writing count=0 WHILE count EQ 0 DO BEGIN ; files=find_files(file,count=count) files=file_search(file,count=count) wait,wtime ENDWHILE prev_size=0. finfo=file_info(file) size=finfo.size WHILE size NE prev_size DO BEGIN wait,wtime prev_size=size finfo=file_info(file) size=finfo.size message,'size='+strtrim(size,2)+'prev_size='+strtrim(prev_size,2),/info ENDWHILE END