remove \r from check_keyword

last commit of simplification mainly aims to remove \r from input
adjust coding style of check_keyword