Update sp.py

now with file IO