Correctly Moving along a path

I am trying orient the camera on a predefined path by continuously updating camera position and target location.
I do see some movement but does not seem to be right.How to ensure that the camera always looks ahead the path?
The example I am trying to modify is here


    int i = 0;
    vPathPoints=GetPathPoints();//Custom function to load path data(smooth curve)

    // Game loop
    while (!glfwWindowShouldClose(window))
    {
      //Code from the camera sample.
        i++;
        camera.Position = glm::vec3(vPathPoints[i].x, vPathPoints[i].y, vPathPoints[i].z);
        camera.Front = glm::vec3(vPathPoints[i + 1].x, vPathPoints[i + 1].y, vPathPoints[i + 1].z);
        //VIEW
        // Create camera transformation
        glm::mat4 view;
        view = camera.GetViewMatrix();
        //PROJECTION
        glm::mat4 projection;
        projection = glm::perspective(camera.Zoom, (float)screenWidth / (float)screenHeight, 0.1f, 10000.0f);
        // Get the uniform locations
        GLint modelLoc = glGetUniformLocation(ourShader.Program, "ModelMatrix");
        GLint viewLoc = glGetUniformLocation(ourShader.Program, "ViewMatrix");
        GLint projLoc = glGetUniformLocation(ourShader.Program, "ProjectionMatrix");
        // Pass the matrices to the shader
        glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view));
        glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(projection));
        //MODEL
        // Calculate the model matrix for each object and pass it to shader before drawing
        glm::mat4 model;
        model = glm::translate(model, cubePositions[0]);
        GLfloat angle = 0.0f; // For now no rotation required  ???
        model = glm::rotate(model, angle, glm::vec3(1.0f, 0.0f, 0.0f));
        glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));

      ///
  }