Added --write-output option