Improved text writing script