Can I use infinite numbers in a reduction? I have to reduce $L_\text{empty}$ to $L_\text{inf}$

where 

$\qquad L_\text{empty} = \{e \mid |L(P_e)| = 0 \}$ and
$\qquad L_\text{inf}= \{e \mid |L(P_e)| = \infty \}$.

where $P_e$ is the program with Gödel number $e$, and $L(P_e)$ the language it accepts.

So can I define a program $P$ like this

input n
Run Pe on 1...n for n steps
if Pe accepts any number then 
  enter an infinite loop and start accepting infinite number
if Pe does not accept any number then 
  accept 1


Now if I can define program P like above then asking the question whether the index of $P$ is in $L_\text{inf}$ will tell me whether the language accepted by $P_e$ is empty or not.
A language cannot contain infinite numbers, since by definitions it is a set of finite numbers. The language itself could be infinite, though: it could contain infinitely many numbers.

In your solution, in the first case, you first enter an infinite loop and then "start accepting infinite numbers", but once you've entered an infinite loop, you're not accepting anything.

Your reduction $f$ has to satisfy the following two properties:


If $e \in L_{\mathrm{empty}}$ then $f(e) \in L_{\mathrm{inf}}$.
If $e \notin L_{\mathrm{empty}}$ then $f(e) \notin L_{\mathrm{inf}}$.


In plain English:


If $L_e$ accepts no inputs then $L_{f(e)}$ should accept infinitely many inputs.
If $L_e$ accepts at least one input then $L_{f(e)}$ should accept finitely many inputs.


Try to see if you can come up with such a function $f$. The basic idea is similar to yours - on input $n$, $f(e)$ should check whether $L_e \cap \{1,\ldots,n\} \neq \emptyset$. You should just be more careful in what happens next.