Added key press exit and fixed syntax errors