Made some obvious changes.
next write method to check if tor is running else start tor.