Python/Arduino interfacing issue.

I have a sketch on my Arduino sending an analog pin value to the computer through serial.println.... It is working fine. I am trying to read that value through python using the PySerial library. My python code is this:
import serial
ser = serial.Serial('COM4', 9600)
while 1:
ser.readline()
When I put the code in a line at a time through the python shell it works but if I try to run it from a saved file (F5) it gives me this error:
Traceback (most recent call last):
File "C:\Users\Peter\Dropbox\3D printer\Python Interface.py", line 2, in
ser = serial.Serial('COM4', 9600)
File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 30, in init
SerialBase.init(self, *args, **kwargs)
File "C:\Python27\lib\site-packages\serial\serialutil.py", line 260, in init
self.open()
File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 56, in open
raise SerialException("could not open port %s: %s" % (self.portstr, ctypes.WinError()))
SerialException: could not open port COM4: [Error 2] The system cannot find the file specified.

I am running the code on a win7 64 bit Toshiba laptop running win7 ultimate 32 bit. Python verision 2.7.2
Thanks in advance,
Peter

No Python expert but I once wrote this one, you can adapt it quite easily

import sys, os, serial, threading

def monitor():

    ser = serial.Serial(COMPORT, BAUDRATE, timeout=0)

    while (1):
        line = ser.readline()
        if (line != ""):
            #print line[:-1]           # :-1  means until last - 1 ==> strip \n
            fields = line[:-1].split('; ');    # split in fields
            ID = fields[0]
	    TIME = int(fields[1])

            # print fields
            print "device ID: ", ID

            # write to file
            text_file = open("Pdata.log", "w")
            text_file.write(line)
            text_file.close()

        # do some other things here

    print "Stop Monitoring"


""" -------------------------------------------
MAIN APPLICATION
"""  

print "Start Serial Monitor"
print

COMPORT = 4;
BAUDRATE = 115200

monitor()