added more debugging output when length not matched, added missing testFlag initialization, added testFlag passing to read_file()