Changed writeOut() to work as expected