A fatal error with Arduino and Python

I hope this will provide a better idea of what I need. I'm not even sure it is possible though.

http://stackoverflow.com/questions/15998425/python-serial-arduino-surviving-loss-of-connection

I'm running this script to test the Serial connection between an Arduino and Python before I try to send and receive information between the two.

If the Arduino is unplugged/re-plugged during while ser.read(), it will never restart from where it left off due to never receiving anything but a '1' from the Arduino>Serial.

What is a better way to write this that ensures the Serial connection can restart the script from the beginning after being unplugged?

from pprint import pprint

import time
import serial

while True:
    #the connection to the arduino
    try:
        ser = serial.Serial('COM13',9600)
    except IOError:
        connected = False
        pprint('Arduino not connected to COM13')
        time.sleep(3)
        continue
    serin = ser.read()
    connected = True
    pprint('connected to arduino')
    ser.write('1')
    while ser.read() == '1':
        pass
    pprint ('Arduino has finished flash')

ser.close()
    pprint('connection closed')

time.sleep(5)