Open files in subfolder

Hi community,I am modifying a script for processing images in subfolders of my main folder. But for some reason it can not open files in subfolders. And I got error like shown in the image.
Thanks so much
The script is like:


//#@ File (label = "Input directory", style = "directory") input
//#@ File (label = "Output directory", style = "directory") output
//#@ String (label = "File suffix", value = ".tif") suffix

processFolder(input);

// function to scan folders/subfolders/files to find files with correct suffix
function processFolder(input) {
	list = getFileList(input);
	filelist = Array.sort(list);
	for (i = 0; i < lengthOf(filelist); i++){
		if(File.isDirectory(input + File.separator + filelist[i])){
			// test read subfolder
			processFolder(input + File.separator + filelist[i]);
		}	
		if(endsWith(filelist[i], ".tif")){
			processfile(input, output, filelist[i]);
		}
	}
}
function processfile(input, output, file) {
		if(matches(filelist[i], ".*MAX_Green.*")){
			file = filelist[i];
			filename = File.getNameWithoutExtension(file);
			**open(file);**
		} 
		print("Processing: " + input + File.separator + file);
		print("Saving to: " + output);
}

image