Added error handling (nonexisting file, JSON format)