In order to draw a line with the game engine, we'll need to start with an object. The reason for this is that we cannot execute a python script in the game engine without an object to execute that script.
Since the line is the focus here, we can use an empty so there will be no object rendered in the game.
On the left is the viewport, and on the right what the game looks like when we play it. Now we have an object to execute our python script, so we can go ahead with setting that up.
To do this we will need to use the Logic Editor which can be found here:
Once we are in the Logic Editor we need to add an always sensor and a python controller from the menus at the top. One you have them, drag and drop to connect the output from the Always sensor to the input of the Python controller. Finally we should chack True level triggering (The three raised dots) on the Always sensor. This will make the sensor trigger the controller every logic tick (which is 60 times per second by default if I recall correctly. Also note this isn't necessary to draw a line, but if you plan on adding anything requiring that will require updates while playing then it's a good idea).
One all that is done the Logic Editor should look like this:
The final step is to create the Python script and select it in the Python Controller. Open up the text editor, create a new text file and add the two lines of code. You already know how to do this part, but for those who don't the code is:
Once you have your script (in my case the text file is simply called Text, but a more descriptive name would be better), save it to your computer by opening the Text menu in the text editor and choosing Save. Finally, select the test file in the field on the Python controller.
On the left is the controller, and on the right the text file that includes our script.
All that's left to do now is play the game. I recommend saving your blend file first, just in case. Then hover your mouse over the 3d view and press P to play the game. If the game doesn't start, make sure you are using the Blender Game engine, and not he Blender Render Engine or Cycles. If all went well, your game will look like this:
EDIT: It is a better idea to try to figure out the problem yourself, rather than ask for a complete guide, the simple reason being you will learn how things work a lot better by trial and error than by following a tutorial. If you have more problems like this in the future, try figuring out your problem by yourself, and then ask a single question about the first issue you encounter. If you simply don't know where to start, you can ask how you should go about starting. If you don't know how to execute a script properly, then ask that. In general, ask questions that solve your current issue and nothing more. That way you are forced to learn how to do something, as well as why it works that way, instead of just being able to follow a guide (I say this all from personal experience).