Text in a file

i have a simple list that i want my script to use it contains names and numbers i want the script to display an entry if it exists or add an entry if it dosnt exist in the txt file. My list
example is:
john smith:12345678
sally williams 87654321

so how do i let my script display a name if found of add to the list if not there.
Thankyou for any help you can give me.

Here is a ksh version. It will only append an entry if a capital A is passed as the third argument. Make sure you enclose the first argument in quotes! You can get some unpredictable results and/or corrupt your file if you don't and you have some spaces or special characters in there.

To use it:

./scriptname "John Smith: 555-123-4567" filename A
#!/usr/bin/ksh
if [ $# -lt 2 ]
then
    print "Usage: $0 entry filename [A]"
fi

if [[ `grep $1 $2` != "" ]]
then
   grep "$1" "$2"
elif [[ $3 == A" && `grep $1 $2` != "" ]]
then
   print "$1" >> "$2"
else
  cat $2
fi