Changed string appending; changed file close location