Change format option default value to 'txt' instead of null
Add checking for unsupported formats