added saveScript function to save all commands as a file