Moved write ouput to global