changed file stream code