fixed mistakes in 'write'