replaced file stream with socket