Simple custom raycast not removing correct block in my Minecraft clone

this is supposed to check in front of the player at several points going forward. When it detects that it is inside a block, it removes it with editblock. I also made it spawn a small cube at the last increment point for debugging. The problem is, it will remove a block that I'm not looking at in a pattern I havent recognized. It also spawns the debug cube in the wrong position, which is supposed to be just further than where it detects that the point is in a block.

Transform currentPos = transform;
float step = 0.06f;
bool inBlock = false;
int max = 5000;
int dist = 0;
while (!inBlock)
{
    if (chunk.BlockIDs[Mathf.FloorToInt(currentPos.position.x), Mathf.FloorToInt(currentPos.position.y), Mathf.FloorToInt(currentPos.position.z)] == 1)
    {
        chunk.editBlock(Mathf.FloorToInt(currentPos.position.x), Mathf.FloorToInt(currentPos.position.y), Mathf.FloorToInt(currentPos.position.z));
        inBlock = true;
    }
    if(dist > max)
    {
        inBlock = true;
    }
    currentPos.position = currentPos.position + (currentPos.forward * step);
}

Instantiate(cube, currentPos.position, new Quaternion());                

(Ive been trying different solutions for a few hours, and took this concept from a youtube video) please ask if I didnt give you enough information