Local max values of a file

I have a data file of two columns (corresponding to the x and y axes of a graph) separated by a comma. I want to find the local maximum values and print them to a file. It has been a while since I've done any scripting and I've forgotten everything. I have a few basic questions.

1.) How do you read a file into a script? I know how to set a variable as a file and to access the file, I just can't recall how to make the file itself a variable to be read into the script.

2.) One a file is set to a specific variable name, how do I access a specific element? (i.e. row and column)

For instance, if I have a file 'data' with composed of the following:

12 23
15 49
19 22
20 12
34 39
45 1
60 56
89 79

I want a to make a file with

15 49
34 39
89 79

but I'm just having trouble remembering how to access the specific elements. i.e. the second column first element.

Any help or direction towards a good resource would be greatly appreciated. Thank you.

-John

This seems to do the trick!

#!/bin/sh

#This file calculate the local maximum values in the second column 
#of a file consisting of two columns and creates a file of this data.  
#
#$1 represents the first input variable:  the input file
#$2 represents the second input variable: the output file

input_file=$1
output_file=$2
i=0
j=0

 while read line
   do
   i=`expr $i + 1` 
   eig[$i]=`echo $line|awk '{print $1}'`     #eig and strain are arrays from 1 to length of file
   strain[$i]=`echo $line|awk '{print $2}'`
 done < $input_file

eig[$i+1]=0
strain[$i+1]=0

while [ $j -lt $i ]; do
   j=`expr $j + 1` 
   if [ j == 1 ]; then 
      if [ ${strain[$j]} -gt ${strain[$j+1]}  ]; then
         echo ${eig[$j]} , ${strain[$j]} >> $output_file
      fi
   else
      if [ ${strain[$j]} -gt ${strain[$j+1]} ] && [ ${strain[$j]} -gt ${strain[$j-1]} ]; then
         echo ${eig[$j]} , ${strain[$j]} >> $output_file
      fi
   fi
done