Added null terminator to the end of array of output array
Added input arg verification.