Let us assume that a gravitational field is created by a mass $M$. An agent is bringing a unit mass from $\infty$ to distance $r < \infty$, both measured from mass $M$.
The agent is always forcing the unit mass with a continuously changing force $\vec F(\vec x)$, $\vec{x}$ being the distance pointing radially out from $M$.
According to classical mechanics, it holds that $\vec F(\vec x) = \frac{GM}{x^2}\hat{x}$, with $G$ being the gravitational constant.
The work is calculated as follows: $$W = \int_\infty^r\vec F(\vec x)\cdot d\vec x$$ $$=\int_\infty^r{{F(x)}\,dx\cdot cos(\pi)}$$ $$=-\int_\infty^r{{\frac{GM}{x^2}}dx}$$ $$=-GM[-\frac{1}{x}]_\infty^r$$ $$=GM[\frac{1}{x}]_\infty^r$$ $$=GM[\frac{1}{r}-\frac{1}{\infty}]$$ $$=\frac{GM}{r}$$
The body moved against the force's direction (the angle between them was always $\pi$). So the work should have been negative. But since $r$ is the scalar distance from $M$, it is positive like $G$ or $M$, yielding the result always positive.
What is wrong here?