Try this (tested) code to see of its what you are after.
Code:
	var fhandle = file_open_read("diag.txt");
	var groups=0;
	while(eof != -1)
	{
		eof = file_str_read(fhandle, test_str);
		if(eof>0) 
		{
			if(str_to_asc(test_str)==str_to_asc(_str("[")))								// <<- can be simplified to if((test_str.chars)[0]==91)
			{	
				groups += 1;	//increment group counter
				str_clip(test_str,1);	//remove leading "["
			}
			if((test_str.chars)[str_len(test_str)-1]==str_to_asc(_str("]")))		// <<- can be simplified to if((test_str.chars)[str_len(test_str)-1]==93)
			{	str_trunc(test_str,1);	/*remove any "]"*/	}		
			str_cpy( (dialog_file.pstring)[count], test_str);		//Push lines into array
			count += 1;		//increment total-strings count
		}
	}






"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial