Refactored script to python. Removes need for coreutils