modified to output errored lines to file