package main import ( "bufio" "fmt" "log" "os" "strings" ) func main() { fname := "input.txt" if len(os.Args) > 1 { fname = os.Args[1] } f, err := os.Open(fname) if err != nil { log.Fatal(err) } defer f.Close() grid := [][]string{} scanner := bufio.NewScanner(f) for scanner.Scan() { line := scanner.Text() row := strings.Split(line, "") fmt.Println(row) grid = append(grid, [][]string{row}...) } fmt.Println(grid[0][0]) if err := scanner.Err(); err != nil { log.Fatal(err) } }