You can make this work with file descriptors or as jlliagre suggests redirecting rez.txt as input to the while. Here is a portion of your script with the file descriptor statements added.
Code:
...
gcc "$DEST_DIR/$IDEST_DIR/tema.c" -o "$DEST_DIR/$IDEST_DIR/tema" -O2 -Wall -lm -pedantic 2> "$DEST_DIR/$IDEST_DIR/rez.txt"
exec 3<$DEST_DIR/$IDEST_DIR/rez.txt
while read -u3 LINE;
do
LEN=${#LINE};
...
echo $ERR_COUNT $WAR_COUNT
done
exec 3<&-
echo $ERR_COUNT $WAR_COUNT
}
The statement
exec 3<$DEST_DIR/$IDEST_DIR/rez.txt opens file descriptor 3 for reading from the rez.txt file.
The statement
while read -u3 LINE; uses the file pointed to by file descriptor 3 as input to read on the while statement.
The statement
exec 3<&- closes file descriptor 3.
Bill