The array appears to be undefining itself prior to it reaching this point in the script. $sof_to_delete is equal to the number of lines parsed through in the previous part of the subroutine. It is so that if I have to look past the last connection to an earlier connection, it is removed from the array prior to the next iteration of the subruotine (if it is called later.)
-Kevin