import serial
import time
import re

select = re.compile("^(\w+ \w+\:\w+)\s{1}(.*)")
#select = re.compile("J*")
ser = serial.Serial(0)
ser.baudrate = 19200
f = open ("Luther_ohneUmlaut.txt","r")


time.sleep(.8)
for line in f:
	found = select.search(line)
	#print found.group(1)
	#print found.group(2)
	ser.write('#') #reset auf position oben mit clear
	print str('#')
	time.sleep(.2)
	for stelle in found.group(1):
		ser.write(stelle)
		#time.sleep(.01)
		print stelle
	ser.write('$') # cursor ohne reset auf zeile 2
	print str('$')
	time.sleep(.1)
	zitat = found.group(2)[0:15]
	for stelle in zitat:
		ser.write(stelle)
		#time.sleep(.01)
		print stelle
	time.sleep(1)
	# zurueck auf start
	
f.close()