added close connection to files