Store thread_id to a .txt file