added try block around csv output