diff --git a/lib/geocoder/lookups/ipapi_com.rb b/lib/geocoder/lookups/ipapi_com.rb
index f38a58370e027b87677183a4e5cc3be95fc5c593..a799297a1867cace4ce0a3dec5e44ca954c93440 100644
--- a/lib/geocoder/lookups/ipapi_com.rb
+++ b/lib/geocoder/lookups/ipapi_com.rb
@@ -31,7 +31,7 @@ module Geocoder::Lookup
     private
 
     def parse_raw_data(raw_data)
-      if raw_data == "invalid key\n" || raw_data == "invalid key"
+      if raw_data.chomp == "invalid key"
         invalid_key_result
       else
         super(raw_data)