Made printArray into a function