I'm trying to prove this fact:
A set $A$ is computable enumerable (c.e.) iff it is either empty or is the image of a total computable function. Moreover, if $A$ is infinite, the function can be taken to be 1:1.
Does this proof look correct?
Suppose $A$ is infinite. $A$ is c.e., so there is a program (enumerator) such that if we run it (with no input), it would spit out all elements of $A$. Define the function $f:N\to N$ by $n\mapsto n\text{th element that the enumerator spits out}$. This function is computable by the following program: it accepts $n$, launches the enumerator, waits until it spits out the $n$th element and outputs the $n$th element. Also, $f$ is total since $A$ is infinite (I guess the above doesn't work for finite $A$). Moreover, $f$ can be taken to be injective by inserting the instruction into the code of the enumerator that says "don't spit out $k$ if $k$ has already been spit out before".
Suppose $A\not= \emptyset$ and suppose $A$ is finite. Say $A=\{x_1,\dots,x_m\}$. Define the function $N\to N$ by sending $i$ to $x_i$ provided $i\in \{1,\dots, m\}$ and by sending all other $i$ to (for example) $x_1$. This function is total and is computable by this program: it accepts $i$, checks whether $i\in \{1,\dots, m\}$ and then either outputs $x_i$ or outputs $x_1$.
Conversely, Suppose $A$ is the image of a total computable function $f$. Let $p$ be the number of a program computing $f$. Here's how to construct an enumerator for $A$: for each $n=0,1,2,\dots$, run $\phi_p(n)$, print the output, replace $n$ with $n+1$, and repeat. This works for finite or infinite $A$. (Maybe not for empty $A$.)