I guess this this will roughly do the job. Try to combine with your own code, instead of just copy-pasting into your homework solution.
#!/bin/bash
echo -n "enter town: "
read caller_town
town_id=$(grep "|$caller_town|" towns.txt | awk -F '|' '{ print $1; }')
while read line; do
caller_id=$(echo "$line" | awk -F '|' '{ print $1; }')
egrep "\|$caller_id\|[0-9]+\|$town_id$" calls.txt > /dev/null
if [ $? -eq 0 ]; then
echo "$line" | awk -F '|' '{ print $2; }'
egrep "\|$caller_id\|[0-9]+\|$town_id$" calls.txt
echo
fi
done < subscribers.txt