add first version of the script (original write function was grabbed from codegolf)