TITLE: Flat non-trivial $U(1)$-bundle? Is it possible?
QUESTION [11 upvotes]: maybe this is a very stupid question and I'm missing something very trivial.
It's well known that $U(1)$-bundles are classified by the Euler class or the first Chern class. More precisely, the isomorphism $$c: \check{H}^1 (X, \mathscr{C}^{\infty} (-, U(1))) \xrightarrow{\sim} H^2 (X, \mathbb{Z})$$, induced by the exact sequence $0 \rightarrow \mathbb{Z} \rightarrow \mathbb{R} \xrightarrow{exp} U(1) \rightarrow 0$, the sheaf isomorphism $\mathscr{C}^{\infty} (-, \mathbb{Z}) \cong \mathbb{Z}_X$ and the isomorphism from \v{C}ech to singular cohomology (or de Rham cohomology with integral periods), is the first Chern class or the Euler class. 
It's well known too that the first Chern class is given by $$[\frac{1}{2\pi i}F_{\nabla}]$$. This equality can be accomplished by using that the first Chern class is equal to the Euler class, the global angular form $\psi$ restricts to the Maurer-Cartan form on each fiber and every connection is of the form $\psi + \pi^{*} \alpha$ for some $\alpha \in \Omega^1 (X, \mathfrak{u}(1))$, where $\pi: P \twoheadrightarrow X$ is the $U(1)$-bundle 
1) From these two remarks, one can conclude that if $F_{\nabla} = 0$ on some circle bundle $P$, then $c_1 (P) = 0$ and, therefore, $P$ is trivial. 
However it's well known too that in the theory of Cheeger-Simons  differential characters $$H^1 (X, U(1))$$ classifies flat $U(1)$-bundles with connection by assigning the holonomy $$\text{Hol}_{\nabla} (z) = \langle c, z \rangle$$ for every $z \in Z^1 (X, \mathbb{Z})$ to each $[c] \in H^1 (X, U(1))$ and using the canonical pairing coming from the fact that $U (1)$ is divisible and, hence, $H^1 (X, U(1)) = \text{Hom} (H_1 (X, \mathbb{Z}), U(1))$. 
2) Therefore it may exist non-trivial bundles with flat connection whenever the first cohomology does not vanish.
Having this in mind, why there's a non-trivial flat $U(1)$-bundle? 
In other words, what's wrong in my conclusions in 1 and 2?
Thanks in advance.

REPLY [3 votes]: Topological line bundles are classified by $H^1(X, U(1)) \cong H^2(X, \mathbb{Z})$ where $U(1)$ has the usual topology. Flat line bundles are classified by $H^1(X, U(1)) \cong \text{Hom}(H_1(X), U(1))$ where $U(1)$ has the discrete topology; this is often denoted by $U(1)_d$. There's a natural map 
$$H^1(X, U(1)_d) \to H^1(X, U(1)) \cong H^2(X, \mathbb{Z})$$ 
sending a flat line bundle to its first Chern class, and Chern-Weil theory implies that if $X$ is a smooth manifold then this class has image zero in de Rham cohomology. But as Mike Miller says this only implies that it's torsion, not zero.