Fixed the infinite loop and changed formatting

Fixed the infinite loop due to the cursor never iterating. Program only
works for one calendar and events seem to not be writing back to the
calendar