added platform-specific writing.