First full version of python version of bash script. Does exactly the same thing.