Fix bug in -w and added exit statuses for unsuccessful runs