rotating stick

Hi, I’m quite new to blender, and so far, I think it’s the best tool for my 3d Project.
I want to make a sequential moving representation of a stick with the origin at 0,0,0 and pointing to any xyz coordinates, which are read from a “trajectory.cvf” file which contains the sequence of xyz in lines as follows:
3,4,7
2,0,6

I started using a thin cone (to show where it’s pointing to) and managed to run two functions: read the file data, and orient it correclty. What I’ve not been able is to handle the timing. When I press “p” in game mode, i just see the complete execution and the image shown corresponds to the latest position. I don’t need to run very fast (1 or 2 frames per second could be enough).
Any help is welcomed. I copy down here my script (sorry, the indent dissapeared in the post).
PS.: (After I get this working, I’ll want to be more ambicious and continue adding more stics to the scene, more trajectories, and might be, read the data from network instead of a file.)

import bge
from bge import *

import math
import mathutils
from mathutils import Vector

cont = bge.logic.getCurrentController()
own = cont.owner

Create a vector function

def DrawVector(x,y,z):

v = Vector((x,y,z))
#Set origin
up = Vector((0,0,1))

rot = up.rotation_difference(v)

q0=rot[0]
q1=rot[1]
q2=rot[2]
q3=rot[3]
#http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
me00 = q0*q0 + q1*q1 - q2*q2 - q3*q3
me01 = 2 * (q1*q2 - q0*q3)
me02 = 2 * (q0*q2 + q1*q3)
me10 = 2 * (q1*q2 + q0*q3)
me11 = q0*q0 - q1*q1 + q2*q2 - q3*q3
me12 = 2 * (q2*q3 - q0*q1)
me20 = 2 * (q1*q3 - q0*q2)
me21 = 2 * (q0*q1 + q2*q3)
me22 = q0*q0 - q1*q1 - q2*q2 + q3*q3

own.worldOrientation[0] = (me00, me01, me02)
own.worldOrientation[1] = (me10, me11, me12)
own.worldOrientation[2] = (me20, me21, me22)

Create a readfile function

def readfile():
global Matrix
Matrix = [[0 for x in range(3)] for x in range(45)]
# open the file we just wrote
try:
infile = open(“C:/Users/0202806/Documents/trajectory.csv”, “r”)
for i, line in enumerate(infile, 1):
x, y, z = line.strip("
[]").split(",")
Matrix[i-1][0]=float(x)
Matrix[i-1][1]=float(y)
Matrix[i-1][2]=float(z)
except:
print(‘Error reading file’)
else:
infile.close()
print(“done”)

def main():
readfile()
for i in range(0, 45):
DrawVector(Matrix[i][0], Matrix[i][1], Matrix[i][2])

main()