Troubles understanding the independence of events I have troubles to understand when an event is independent and when not. So I don't understand one step in the solution to this exercise:

We have $X,X_1,X_2,\dots$ be i.i.i. real random variable with density $f(x)$ and distribution function $F(x)$. Further $k\in \mathbb{N}$ and $t\in\mathbb{R}$ and 
  $$N:=\inf\{k\in\mathbb{N}:X_k>X\}$$
  Show $$P(N=k,X\leq t)=\int_{-\infty}^t F(x)^{k-1}(1-F(x))f(x) \, \mathrm{d}x$$

Then the solution says this:

By the definition of $N$ and independence of $(X,X_1,\dots,X_k)$ we have
  $$P(N=k,X\leq t)=P(X_1,\dots,X_{k-1}\leq X,X_k>X,X\leq t) \\ \underbrace{=}_{(*)} \int_{-\infty}^t P(X_1,\dots,X_{k-1}\leq X,X_k>X)f(x) \, \mathrm{d}x = \int_{-\infty}^t F(x)^{k-1}(1-F(x))f(x) \, \mathrm{d}x$$

Does this imply that $\{X_1,\dots,X_{k-1}\leq X,X_k>X\}$ is independent of $\{X<t\}$ or why can I write the integral after $(*)$ like that? Both events have the random variable $X$, so both events should be dependent?
Why can I write the event $\{X<t\}$ as an integral and the other event stays in $P(X_1\dots)$ form?
My second question is about $N$. $N$ is clearly dependent on $X_1,\dots,X_k$ but is it also dependent on $X$?
Thank you for explanation.
 A: The second equality is not quite right and should read
$$
P(X_1,\ldots,X_{k-1}\leq X,X_k>X,X\leq t)=\int_{-\infty}^t P(X_1,\ldots,X_{k-1}\leq x,X_k>x)f(x)\,\mathrm dx.
$$
To realize this, note that we may write the probability as an iterated integral
$$
\begin{align}
\mathrm{E}[\mathbf{1}_{X_1,\ldots,X_{k-1}\leq X}\mathbf{1}_{X_k>X}\mathbf{1}_{X\leq t}]&=\int_{\mathbb{R}^{k+1}} \mathbf{1}_{x_1,\ldots,x_{k-1}\leq x}\mathbf{1}_{x_k>x}\mathbf{1}_{x\leq t}\,P_{(X,X_1,\ldots,X_k)}(\mathrm dx,\mathrm dx_1,\ldots,\mathrm dx_k)\\
&=\int_{\mathbb{R}}\int_{\mathbb{R}^k}\mathbf{1}_{x_1,\ldots,x_{k-1}\leq x}\mathbf{1}_{x_k>x}\mathbf{1}_{x\leq t}\,P_{(X_1,\ldots,X_k)}(\mathrm dx_1,\ldots,\mathrm dx_k)\,P_X(\mathrm dx)\\
&=\int_{-\infty}^t\int_{\mathbb{R}^k}\mathbf{1}_{x_1,\ldots,x_{k-1}\leq x}\mathbf{1}_{x_k>x}\,P_{(X_1,\ldots,X_k)}(\mathrm dx_1,\ldots,\mathrm dx_k)\,f(x)\mathrm dx
\end{align}
$$
where we have used that $P_{(X,X_1,\ldots,X_k)}=P_X\otimes P_{(X_1,\ldots,X_k)}$ by independence as well as Tonelli's theorem. 
The innermost integrals is seen to equal $P(X_1,\ldots,X_{k-1}\leq x,X_k>x)$.
A: The formula below is not the result of the independence, but the definition of $N$
$$P(N=k,X\leq t)=P(X_1,\dots,X_{k-1}\leq X,X_k>X,X\leq t)$$
If $N=k$, by definition ,it means that $$X_1,\dots,X_{k-1} \leq X  $$ and $$ X_{k}>X$$
Now, how to derive  $P(X_1,\dots,X_{k-1}\leq X,X_k>X,X\leq t)$ ?
We use the law of total probability for  the continuous variable $X$ that is 
$$P(X_1,\dots,X_{k-1}\leq X,X_k>X,X\leq t)=\int\limits_{-\infty}^{\infty} P(X_1,\dots,X_{k-1}\leq x,X_k>x,x\leq t)f(x)\mathrm{d}x$$
This is where you made a mistake, you used $X$ instead of $x$. The former being a random variable, the latter a real.
We have one deterministic condition $x<t$, therefore $$P(X_1,\dots,X_{k-1}\leq x,X_k>x,x\leq t)=P(X_1,\dots,X_{k-1}\leq x,X_k>x)1_{x \leq t}$$
Thus,
$$P(X_1,\dots,X_{k-1}\leq X,X_k>X,X\leq t)=\int\limits_{-\infty}^{t} P(X_1,\dots,X_{k-1}\leq x,X_k>x)f(x)\mathrm{d}x$$
How to derive $P(X_1,\dots,X_{k-1}\leq x,X_k>x)$ ? The only random variables in there are $X_1,..., X_k$ which are independent, and identically distributed in other words $$P(X_1,\dots,X_{k-1}\leq x,X_k>x)=F(x)^{k-1}(1-F(x))$$
