title: Reading specific characters from file in Golang
body: <p>I want to read a text  file character by character and print invalid input for those characters that exceed "H"and numbers that exceed "8".
   eg: my input is </p>
  
  <pre><code>I9,A2
  A10,C3
  D2,L3
  </code></pre>
  
  <p>output:
  invalid input for all three</p>
  
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import (
      "bufio"
      "fmt"
      "log"
      "os"
  )
  
  func readLines(path string) ([]string, error) {
      file, err := os.Open(path)
      if err != nil {
          return nil, err
      }
      defer file.Close()
      var lines []string
      scanner := bufio.NewScanner(file)
      for scanner.Scan() {
          lines = append(lines, scanner.Text())
      }
      return lines, scanner.Err()
  }
  
  func main() {
      lines, err := readLines("chessin.txt")
      if err != nil {
          log.Fatalf("readLines: %s", err)
      }
      var numLines int = len(lines)
      for i := 0; i &lt; numLines; i++ {
          for j := 0; j &lt; len(lines[i]); j++ {
              if j &gt; 'H' {
                  fmt.Printf("invalid input")
              }
          }
      }
  }
  </code></pre>