updated for linux OS

rewrote typewrite function to work on both Windows and linux.