This expression seems to catch all the lines as satisfying the if statement, but I want it to catch only the City: line. How do I put a regex for that here?
You're using an assignment (if ( $6 = "City: " )) instead of a comparison (if ( $6 == "City: " )). Depending on your actual input, you might want if ( $6 ~ /City: / ) - using a regex - instead.