We want to show that if $x|y^2$ then $x|y$. Is this contrapositive proof correct?
Proof by contrapositive: Assume $x \not| \;y$ and $x,y \in Z$. Thus, $y=xk+r$ for $k \in Z, r \in N, r < k$ by definition of not divides (there is a remainder). Hence, $y^2=(xk+r)^2=x^2k^2+2xk+r^2=x(xk^2+2k)+r^2$ for $r^2, xk^2+2k \in Z$. Therefore, $x \not| \;y^2 $ because there is a remainder $r^2$