Added writescp function