Changed for loops to while loops to handle blank lines