Fix "wrong task ID written to log" bug

Why is this change necessary?
Un-updated task ID after task addition/deletion (task IDs are supposed
to be updated dynamically according to the arraylist index of task) is
written to log file.

How does it address the issue?
The bug is caused by writing the tasks to task log before updating the
task IDs. To fix it, the order of these two executions are swapped.