Take a look at the following simplex tableu:
The pivot element is at (1,1) with a value of 2. Eliminating other rows I get the next tableu:

That is the last step since there is no negative values in the last row, so it's time to extract the solution.
I read from many sources that in order to extract solutions for $X_i$ variables you need to compute $X_i=\frac{b_i}{x_i}$ ($X_i$ is a solution, $x_i$ is a value in the tableu) for variables that are basic, while solution for variables that are non-basic is zero. And often it is the case.
But that is not the case for my tableu. Here you can see that $x_2,s_1,s_3$ are basic variables. So solution for $x_1$ should be zero, right?
Even though the $x_1$ is non-basic variable, I can solve for it from the first equation (the first tableu row): $$ 4x_1+s_1+s_2=8 $$ Having slack variables as zeros, I get $x_1=2$. Substituting $x_1$ into the second equation (the second row in the tableu): $$ -x_1+2x_2+s_2=4 $$ I solve for $x_2$ and get $x_2=3$. Which is the correct result.
To confirm that, I solved the linear programming problem using graphical method and got the result $X=(2,3)$:

So $x_1$ has a non zero solution even though it was non-basic variable. What then is the algorithm for extracting the solution from the tableu above? Having written a program, how should it read the solution from the tableu?

When you pivot you divide the pivot row by the pivot entry, so the pivot entry becomes $1$. The nonbasic variables are indeed $0$ in the basic solution, the basic variables are $s_1=8$, $x_2=2$, $s_3=−2$.
However, this is not a feasible solution because negative values are not allowed. You would normally use a Phase I to make the basic solution feasible before starting Phase II to make it optimal. There are several ways of organizing this: consult your textbook.