scan_to_file improvment