Errors that are reported on the for, while, until or case statements mean the actual statement block is incorrect. You have missed out a reserved word for that construct.
The following error below reports the word ‘done’, which is a good clue, since you know it is something to do with a while statement. Looking back through your code check out the while statement for any missing words, like ‘ do ’, or the conditional statement you are using.
syntax error near unexpected token ‘done’ line 31: ‘ done’
The second error is the classic missing quote error. Learn to like this one, because you will see a lot of these. The only solution I offer on this type of error is to ...