printf '<!DOCTYPE HTML><html><head></head><body>' > test.txt
Some odd things are going on here though. The file is listed as “locked” when I open it, and if as TextEdit to unlock it, it fixes the file extension.