I'm having a contradiction with two different classifications of flat complex line bundles over a manifold $X$. Suppose for simplicity that $H^2(X;\mathbb Z) = 0 = H^1(X;\mathbb C)$. Then the only complex line bundle is the trivial one and (thinking in terms of connection 1-forms) isomorphism classes of line bundles with connection become just one-forms on $X$ modulo gauge transformations $\Omega^1(X;\mathbb C) \ni \theta \mapsto \theta^g:=\theta + g^{-1} dg$ where $g: X \to \mathbb C^\times$. If $f: X \to \mathbb C$ is arbitrary and $g = e^f$ then $\theta^g = \theta + df$ is cohomologous to $\theta$. Since $H^1(X;\mathbb C) = 0$ any 1-forms are cohomologous so there is just one equivalence class of flat connections.
On the other hand, the Riemann-Hilbert correspondence says that there is a 1-to-1 correspondence between iso classes of flat line bundles with flat connection and representations of $\pi_1(X)$ on $\mathbb C$. But in the situation above $\pi_1(X)$ can be something like $\mathbb Z/n\mathbb Z$, which has more than one rep on $\mathbb C$.
What am I missing? Is the equivalence of flat bundles under Riemann-Hilbert stronger than gauge equivalence?
The problem is my example isnt possible: if the first homology group has torsion then by the universal coefficient theorem so does the second cohomology.