A blank line between the end of while and start of if would be kind to the reader's eye.