Fixed bug in script writing.