Getting Mesh Vertex by Proximity?

I am currently working on a “dynamic ground sculpting” tool which allows a player to “sculpt” a dynamic mesh by moving a vertex on the mesh in real time. In order to do this, I am currently casting a ray, and attempting to see whether or not it intersects with a dynamic mesh and, if so, attempts to find the vertex closest to the point of collision on the mesh. Most all of this is currently working, I am simply having problems with grabbing a vertex by proximity, as the vertex manipulated in testing seems almost arbitrary compared to the expected closest vertex.

Currently, I have it set up so that it loops through each vertex on a mesh, and attempts to do vector math in order to determine which point is closest to the point of collision. I understand that there is likely a better way to do this, however, in my research I have not yet found a better way to directly reference vertices by location than doing the math out directly.

Any thoughts as to how to fix this/optimize this would be greatly appreciated!