Find string in text file

Hello!

Please, help me to write such script.
I have some text file with name filename.txt
I must check if this file contains string "test-string-first", I must cut from this file string which follows string "keyword-string:" and till first white-space and save it to some variable.
For example. File:

Start 15022011 Eng 12-3-42
SN1232324422 11 test-string-first
SN322211 securities
HH keyword-string:123456@321.net mark (11-22)

This file contains "test-string-first" and I need to get 123456@321.net string (between "keyword-string:" and first space)

try:

var=`awk '/\<test-string-first\>/{getline;getline line;split(line,a," |:");print a[3]}' file
echo $var
123456@321.net 
# cat file
Start 15022011 Eng 12-3-42
SN1232324422 11 test-string-first
SN322211 securities
HH keyword-string:123456@321.net mark (11-22)

Start 15022011 Eng 12-3-42
SN1232324422 11 test-string-first
SN322211 securities
blah blah
HH keyword-string:12343333333@321.net mark (11-22)

blah
blah

$ ruby -0777 -ne '$_.split("test-string-first").each{|x| puts x[/keyword-string:(.[^\s]*)/,1] if x[/keyword/]}' file
123456@321.net
12343333333@321.net

OK! Thnx!
But can I use such structure:

if (check_exists_of('test-string-first','filename.txt') then
 MYVAR = awk .... filename.txt
 echo $MYVAR
else
 echo 'file doesn't contain '''test-string-first@'' string!'
 fi

?
help me pls to change check_exists_of('test-string-first','filename.txt') and MYVAR = awk .... filename.txt statements to the correct.