Why does program stop updating closest object distance?

So what I’m trying to do is have a triangle constantly calculate the closest piece of “food”, but after a while it stops updating/checking the closest “food” and its position. I will include the code in question along with a screenshot to help you understand my problem.

(Also the “seek()” function in question is in the “update()” function in the script that is attached to the triangle if that has any relevance?)

[110211-untitled.png*_|110211]

private void seek()
    {
        targets = GameObject.FindGameObjectsWithTag("Food");
        
        for(int i = 0; i < targets.Length; i++)
        {
            float lastDistance = distBetween(triangleTransform, targets*);*

if (lastDistance < lastClosestDist)
{
lastClosestDist = lastDistance;
closestObject = targets*;*
time = Time.time;
print("Closest Distance: " + lastDistance + " Closest Object: " + closestObject.name);
}
}
}
-----Edit----- Here is the “distBetween()” method for reference(I know this isn’t the problem)
private float distBetween(Transform t, GameObject o)
{
float dx = (t.position.x - o.transform.position.x);
float dy = (t.position.y - o.transform.position.y);
return Mathf.Sqrt((dx * dx) + (dy * dy));
}
_*

lastClosestDist is never reset, so the closest distance ever will remain. always initialize it with the first lastDistance at the start of seek, or start with float.infinity if you want to start 100% save, or just some other large number exceeding you biggest possible distance.

After hexagonius pointed out that I needed to reset lastClosestDist (at the point where the LastDistance was calculated), I discovered that I had to reset it at the start of the seek() function where targets was initialized not “with the first lastDistance at the start of seek”
------EDIT------
For those saying I’m taking credit for hexagonius’s answer, his answer didnt work when I tried it, so I tried a variation of that(putting the code in a different location) which surprisingly actually changes the product of the code(sarcasm). So to provide a clear answer to my question, that actually works, I posted this as the answer but still gave credit to hexagonius at the begining of my answer.