Reading song verses from a file

Report a typo

Patrick has received a text file technologic.txt with the first verse of Daft Punk's hit song Technologic.

He wants to print the contents of the file line by line in his Go program; this is the code he has written so far:

package main

import (
    "bufio"
    "fmt"
    "log"
    "os"
)

func main () {
    file, err := os.Open("technologic.txt")
    if err != nil {
        log.Fatal(err)
    }
    defer file.Close()

    scanner := bufio.NewScanner(file)

    for scanner.Scan() {
        // What is the missing code line here to print the file contents?
    }
}

Please help him out by entering the missing code line below to print the file contents line by line:

Enter a short text
___

Create a free account to access the full topic