package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strings"
)

func printFile(filename string) {

	file, err := os.Open(filename)
	if err != nil {
		panic(err)
	}
	scanner := bufio.NewScanner(file)

	for scanner.Scan() {
		fmt.Println(scanner.Text())
	}
	printFileContests(file)
}
func printFileContests(reader io.Reader) {
	scanner := bufio.NewScanner(reader)
	for scanner.Scan() {
		fmt.Println(scanner.Text())
	}
}

func main() {

	printFile("test.txt")
	var str string = "dafwef"
	s := `test.txt
		sdfasdf
wefwef	wefwef"wefwefwfe"   
		`
	printFileContests(strings.NewReader(s))
	printFileContests(bytes.NewBufferString(str))
}
