Comparing rows in same file and writing the result in new file

Help needed...

Can you tell me how to compare the last two couple entries in a file and print their result in new file..:confused:

I have one file
Check1.txt

 
\abc1   12345
\abc2   12327
 
\abc1   12345
\abc2   12330
 

I want to compare the entries in Check1 and write to another file :

check2.txt :

 
<current _date & time >
\abc1   <blank since there is no change>
\abc2    3   (This is obtained by subtracting 12330 - 12327)

The check1.txt will be appended by new entries at every hour. Again the difference between the new entry and the entry just above must be compared as in previous case.
i.e. I need to check the difference for every last 2 couple entries only....

Please help me regarding the same....

grep -vE ^[:blank:]*$ input | tail -4 >/tmp/last4lines
check(){
if [[ $1 != $3 ]] 
then
echo "ERROR : cannot compare different first fields"
else
let res=$4-$2
[[ $res = 0 ]] && echo "$a" || echo "$a $res"
fi
}
sed '1~2' /tmp/last4lines | xargs | read a b c d
eval check $a $b $c $d >>output
sed '2~2' /tmp/last4lines | xargs | read a b c d
eval check $a $b $c $d >>output