read file and validate inputs