I am trying to comprehend how path-connectedness of a topological space is proved in essence to solve another problem (to prove the plane $\mathbb{R}^2$ without a line is not path-connected) and have troubles with it.

There is a quite intuitive definition of path-connectedness: a topological space is path-connected if for any two points in that space there exists a continuous function from a compact $[a,b]$ to that space such that its $f(a)$ and $f(b)$ are equal to those points respectively.

Now, I've made this simple problem (stated in the title) for myself to understand how it's proved.

The way I think (although it's a hand-waving proof, I do not understand the flaw I've made):

Let's split a closet interval $[0,1]$ into semi-intervals like $(x\_1,x\_2]$ with $x\_2 > x\_1$ (and keep the first one starting from 0 to be a closed interval for the sake of symmetry, i.e. the first one is $[0,x]$). Obviously, I can split this interval into countable amount of such semi-intervals. Therefore, since between any two rational points $a$ and $b$ there're countable amount of rationals, I can construct a function mapping these semi-intervals to points in $[a,b]\cap\mathbb{Q}$ (e.g. I can identify each semi-interval with a rational point enclosed in between to get an enumeration and that match each semi-interval to each point in enumerated set of points in $[a,b]\cap\mathbb{Q}$ with some bijection $f:\mathbb{N}\to\mathbb{N}$). A function constructed as such is continuous because for any rational point in $[a,b]\cap\mathbb{Q}$ there exists a whole neighbourhood mapped to this single point.
And since we can construct such a continuous function for any two rational points, Q is path-connected.

Thank you!