Need help with simple script

I work for a small internet company, and sometimes its useful to ping a certain IP over an open amount of time. I wrote a simple script that asks what IP you'd like to ping, and then pings it and puts it into a text file so that you can save the results. What i'd like though, is to have an infinite loop that pings and puts it into a text file, and then, after a certain key is pressed, it stops that part of the script and continues on to the next part, that uses Grep, and filters out the pings so that you just get the time, and and the end part of the ping, where it tells you packet loss and such. This is what I have so far. I know it is likely completely wrong, I'm new to this, and this is what I have combining my script and what I think I want from googling how to use user input to end an infinite loop.

echo 'What IP address would you like to ping?'
read VAR_1
echo "Pinging $VAR_1..."

if [ -t 0 ]; then stty -echo -icanon time 0 min 0; fi

{
count=0
keypress=''
while [ "x$keypress" = "x" ]; do
  echo "
  THE TIME IS: $(date)"
  ping -c 20 $VAR_1
done
} > /home/tyler/Programs/Pinglog\ Results/$VAR_1.txt

if [ -t 0 ]; then stty sane; fi

echo "You pressed '$keypress' after $count loop iterations"
echo "Thanks for using this scipt."

VAR_2=$VAR_12
grep 'TIME\|packet' /home/tyler/Programs/Pinglog\ Results/$VAR_1.txt > $VAR_2.txt

exit 0

Have you looked at this thread:-
http://www.unix.com/unix-dummies-questions-answers/219287-bash-inkey-function.html

I learned a lot for making mistakes and reading what was being done here and the explanations given of my errors.

Robin