While loop inside While working just once in ruby? : <p>I am using while statement in ruby and another child while statement in that parent while to print :</p>

<pre><code>z = 0
  i = 0
  while z &lt; 2
    puts "hi coding"
        while i &lt; 4  do
          puts "hello"
           i +=1
        end
    z +=1
  end
</code></pre>

<p>I want first ("hi coding") is printed and then ("hello,hello,hello,hello" four times) ,  and this total chunk printed twice but what is happening is that hi coding is printed twice and ( 4 times hello just once ):
so my output is like :</p>

<pre><code>hi coding 
hello 
hello
hello
hello
hi coding
*************************
</code></pre>

<p>but i want it as :</p>

<pre><code>hi coding
hello
hello
hello
hello
hi coding
hello
hello
hello
hello
*************************
</code></pre>

<p>what am I doing wrong here ?</p>
