Added logging content, wrapped up primary process in a while loop.