bash: making a count

ok basically im trying to count how many people fail a class by comparing there grade by -gt 49

i tried putting a count inside the while loop but i know you cant access a count outside a subshell. is there an easy way to count the number of failures?

declare -i failcount=0

awk 'match($2,":"){print substr($2,RSTART+1,3)}' class.marks | while read line; do
    if [ $line -gt 49 ] ; then
	(( failcount++ ))
fi
done
echo $failcount

my class.marks file is as follows:

ID4341:Gwen Camper:72
ID4923:Ron Tomm:100
ID4239111:John Snow:40

Why not use awk to count for you

failcount=$(awk -F: '$3>49 {F++} END {print F}' class.marks)
echo $failcount

thank you very much

im just learning unix so i still think java when im programming i was unaware you could do this