This should probably be put into the main body of the while() statement.