The improper integral cannot always be obtained as a limit of Riemann or Riemann-like sums. This is basically a question of whether or not iterated double limits exist and/or are equal. It depends on the nature of $f$. If $f$ is monotone then it usually works out as discussed here.
As a counterexample, take a function $f$ where $f(k) = 1$ at any integer $k$ and $f(x) = 0$ otherwise. Here we have
$$\int_0^\infty f(x) \, dx = 0$$
However, for the sequence $a_n = 2^{-n},$
$$\lim_{a_n \to 0+} \sum_{j=1}^{\infty} a_nf(ja_n) = \lim_{n \to \infty} \lim_{m \to \infty} \frac{1}{2^n} \sum_{j=1}^{m2^n} f(j/2^n) = +\infty$$
That's not exactly what the definition is. The limit should be
$$\lim_{n\to\infty} \sum_{i=1}^n f(x_i)\left(\frac{b-a}{n}\right)$$
i.e., you are summing over $n$ elements. Sure, each of the summands becomes smaller and smaller, but the number of the summands increases at the same rate, so the sum will not always be zero.
In fact, take a look at what happens when $f(x)=1$ for all $x$. In that case,
$$\begin{align}\lim_{n\to\infty} \sum_{i=1}^n f(x_i)\left(\frac{b-a}{n}\right)&=\lim_{n\to\infty}\sum_{i=1}^n 1\cdot\left(\frac{b-a}{n}\right)\\&=\lim_{n\to\infty}\left((b-a)\cdot\sum_{i=1}^n\frac{1}{n}\right)\\&=\lim_{n\to\infty}((b-a)\cdot 1) = \lim_{n\to\infty}(b-a)=b-a\neq 0\end{align}$$
Also, a further word of warning not entirely on topic, but related to your question:
If the Riemann integral of a function over an interval $[a,b]$ exists, then the integral is equal to $$\lim_{n\to\infty} \sum_{i=1}^n f(x_i)\left(\frac{b-a}{n}\right).$$
However, the existance of the limit above does not, in itself, guarantee that a function is Riemann integrable. There exist functions for which
$$\lim_{n\to\infty} \sum_{i=1}^n f(x_i)\left(\frac{b-a}{n}\right)$$
exists, but $\int_a^b f(x)dx$ does not exist.
Best Answer
You seem to be making a right Riemann sum. (Good choice, there are problems with the left Riemann sum.) You wish to replace $x$ ranging over $(0,1]$ with some expression in $k$ which expression gives a subset of $(0,1]$ as $k$ ranges over its index. You have used $k$ with $n = 1, 2, \dots, n$, but this does not produce values in $(0,1]$. (The first one, $k = 1$, is in that interval, but none of the rest are.) Since you seem to be aiming for even spacing with spacing $1/n$ (which appears in front of your sum) the difference between successive sample $x_k$s is $1/n$. This suggests you should replace $x$ with $k/n$, which does range over a subset of $(0,1]$ as $k$ ranges from $1$ to $n$ and does have $1/n$ spacing between samples.
So you should be looking at \begin{align*} \lim_{n \rightarrow \infty} \frac{1}{n} \sum_{k=1}^n \frac{1}{k/n} &= \lim_{n \rightarrow \infty} \frac{1}{n} \sum_{k=1}^n \frac{n}{k} \\ &= \lim_{n \rightarrow \infty} \sum_{k=1}^n \frac{1}{k} \text{.} \end{align*} And, as you observe, this harmonic sum diverges, as expected.