Set brightness to zero -> close the lid -> forget about brightness -> open lid -> doom! No idea if this is only at some OSX release or in all of them... I didn't experience this myself (yet), but ...
For those that are interested in the final script you can get it here original question I am trying to make a alarmclock script to wake me up. but I can't figure out how to change the screen ...