Solution (source code)

= Solution
{c}

The <optional stopping theorem> applies to $M$ at the bounded <stopping time> $n\wedge T_k$. As $M_0=0$, it yields the valid <stopped second-moment identity for a simple symmetric random walk>
$$
\boxed{\mathbb E S_{n\wedge T_k}^2=\mathbb E(n\wedge T_k).}
$$
\b[The printed bound on $\mathbb E T_k$ is false.] Before hitting the positive level $k$, the walk can travel arbitrarily far downwards, so $|S_{n\wedge T_k}|\leq k$ is unavailable.

Here is a valid proof of finiteness of $T_k$. For a positive integer $L$, stop instead at $\tau=\inf\{n:S_n\in\{-L,k\}\}$. The same identity and the bound $|S_{n\wedge\tau}|\leq\max(L,k)$ give
$$
\mathbb E(n\wedge\tau)\leq\max(L,k)^2.
$$
The <monotone convergence theorem> makes $\mathbb E\tau<\infty$, so $\tau<\infty$ almost surely. Applying <optional stopping> to $S$ at $n\wedge\tau$ and then using <dominated convergence> gives $\mathbb E S_\tau=0$. Since $S_\tau\in\{-L,k\}$, this means
$$
\mathbb P(S_\tau=k)=\frac L{L+k}.
$$
Consequently $\mathbb P(T_k<\infty)\geq L/(L+k)$ for every $L$, and letting $L\to\infty$ proves $T_k<\infty$ almost surely.

In fact this is the <infinite mean first passage of a simple symmetric random walk>. If $\mathbb E T_k<\infty$, the first displayed identity would bound the second moments of $S_{n\wedge T_k}$ uniformly. Their <uniform integrability> and their almost sure convergence to $k$ would imply $\mathbb E S_{n\wedge T_k}\to k$. But the <optional stopping theorem> applied to $S$ at every bounded $n\wedge T_k$ makes each expectation zero, a contradiction. Hence the correct conclusion is
$$
\boxed{T_k<\infty\ \text{almost surely},\qquad \mathbb E T_k=\infty.}
$$