if the inverse images of all closed balls are closed, is $f$ continuous? Is the following statement true? (it is asked to be proved true)

If $f: D \to\mathbb R^n$, and for every closed balls $B$ in $\mathbb R^n$, pre-image of $f$ of $B$ is closed in $D$, then $f$ is continuous on $D$. 

I know the analogue of the statement for the openness is true. Because of the fact that every open set is equivalent to the union of certain open balls. However, there is no theorem that any closed set can be written into intersection of closed balls. I am just confused. 
 A: Here is the "universal" counterexample.  Let $D=\mathbb{R}^n$, with the topology which has as a subbasis the sets $\mathbb{R}^n\setminus B$ for all closed balls $B$.  Then the identity map $i:D\to \mathbb{R}^n$ satisfies your condition, but it is not continuous (because, for instance, any nonempty open subset of $D$ contains the complement of a finite union of balls and hence is unbounded).  This is universal in that map $f:X\to\mathbb{R}^n$ satisfies your condition iff there is a (necessarily unique) continuous map $g:X\to D$ such that $f=ig$ (namely, $g$ is $f$ considered as a map to $D$).
On the other hand, there are no counterexamples if you require the function to be bounded.  To show this, we want to show that $i$ is continuous when restricted to any bounded set.  Concretely, this means that if $A\subset\mathbb{R}^n$ bounded, $U\subseteq A$ is open in the usual topology, and $x\in U$, then we can find finitely many closed balls $B_1,\dots, B_m$ such that $x\in A\setminus(B_1\cup\dots B_m)\subseteq U$.  To prove this, note that we may assume $A$ is closed and hence compact, so $A\setminus U$ is also compact.  For each $y\in A\setminus U$, you can choose an open ball around $y$ whose closure does not contain $x$.  Finitely many of these open balls then cover $A\setminus U$ by compactness, and you can take $B_1,\dots,B_m$ to be their closures.
A: I don't think this is true.  What if we define $f: D:= [0, \infty) \rightarrow \mathbb{R}$ by the formula $f(x) = \frac{1}{x}$ for $x > 0$, and $f(0) = 3$.  This function is not continuous, because the sequence $\frac{1}{n}$ converges to $0$, but $f(\frac{1}{n})$ does not converge to $f(0) = 3$.  Another way of seeing this is that the preimage of the closed set $[4, \infty)$ under $f$ is $(0,\frac{1}{4}]$, which is not closed in $D$.
Now, let's check that the preimage of any closed ball $[a,b]$ in $\mathbb{R}$ is closed in $D$.  Let $g$ be the restriction of the function $f$ to the open interval $(0,\infty)$.  Note that $g^{-1}[a,b]$ is closed not only in $(0,\infty)$, but also in $D$.
If $[a,b]$ does not contain $3$, then $f^{-1}[a,b]$ is a subset of $(0,\infty)$, and so $f^{-1}[a,b] = g^{-1}[a,b]$ which is closed in $D$.  If $3 \in [a,b]$, then $f^{-1}[a,b] = \{0\} \cup g^{-1}[a,b]$, with $g^{-1}[a,b]$ closed in $D$.
