Fixed whitespace

In Ruby, you have to use two spaces for indenting!
replaced while(1) with loop