Changed BinaryWriter to StreamWriter