closing txt file and code cleaning