There are two problems here. The one you're seeing is that you're using a dollar sign on the variable you're assigning to -- the dollar sign is used to get the value of a variable, not to set it. Thus, use
a=$(echo "$p" | cut -d: -f1) instead of
$a=$(echo "$p" | cut -d: -f1).
The second problem is in the assignment
file="~/cs/cs3776/assignment2/passwd1.txt" -- the
~ needs to be expanded to the path to your home directory, but that expansion doesn't happen when it's in double-quotes. In this case, there's nothing else there that'd be expanded, so just leaving off the quotes (
file=~/cs/cs3776/assignment2/passwd1.txt) would work. If quotes were needed for the rest of the string, it's possible to partially-quote the string (