Refactor sp.write to accept one parameter