Not using thread anymore to write session file