<commit_before>package main

import (
	"crypto/md5"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"

	"github.com/pkg/errors"
)

// CatFiles copies data from n files to a single one and removes source files
// if Debug mode is set to false
func CatFiles(files []string, outfile string, remove bool) error {
	finished, err := os.Create(outfile)
	if err != nil {
		return errors.Wrap(err, "CatFiles create: ")
	}
	defer finished.Close()
	for _, file := range files {
		fh, err := os.Open(file)
		if err != nil {
			return errors.Wrap(err, fmt.Sprintf("CatFiles open %v: ", file))
		}
		defer fh.Close()
		_, err = io.Copy(finished, fh)
		if err != nil {
			return errors.Wrap(err, "CatFiles copy: ")
		}
		if remove {
			os.Remove(file)
		}<commit_msg>Need to close file before removing<commit_after>package main

import (
	"crypto/md5"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"

	"github.com/pkg/errors"
)

// CatFiles copies data from n files to a single one and removes source files
// if Debug mode is set to false
func CatFiles(files []string, outfile string, remove bool) error {
	finished, err := os.Create(outfile)
	if err != nil {
		return errors.Wrap(err, "CatFiles create: ")
	}
	defer finished.Close()
	for _, file := range files {
		fh, err := os.Open(file)
		if err != nil {
			return errors.Wrap(err, fmt.Sprintf("CatFiles open %v: ", file))
		}
		_, err = io.Copy(finished, fh)
		if err != nil {
			return errors.Wrap(err, "CatFiles copy: ")
		}
		fh.Close()
		if remove {
			os.Remove(file)
		}
{'fraction_non_alphanumeric': 0.14046822742474915, 'fraction_numerical': 0.0013377926421404682, 'mean_word_length': 3.361516034985423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '270913', 'n_tokens_mistral': 577, 'n_tokens_neox': 536, 'n_words': 168}