Unfortunately I'm still new around here and don't have enough reputation yet to comment so this will need to be an answer, hopefully it qualifies.
How are you reading and writing the file? Did you confirm that the file has the control characters embedded properly in a hex editor? You said earlier that your victim reads input from an HTML file, I assume by that you mean it actually reads the HTML file itself? Without knowing exactly how you're reading / writing it I can't be sure, but my guess would be that you're using a stream that filters out control characters appropriately. Something like the code below should work fine for your purposes.
void WriteTarget(const char* FilePath, uintptr_t TargetAddr)
std::ofstream ofs(FilePath, std::ios::trunc | std::ios::binary);
ofs.write(reinterpret_cast<const char*>(&TargetAddr), sizeof(uintptr_t));
void ReadTarget(const char* FilePath)
std::ifstream ifs(FilePath, std::ios::in | std::ios::binary);
auto file_len = ifs.tellg();
uint8_t* file_data = new uint8_t[file_len];
memset(file_data, 0, file_len);
std::cout << "File Contents" << std::endl;
for (auto i = 0; i < file_len; ++i)
std::cout << "0x" << std::hex << std::uppercase << static_cast<uint32_t>(file_data[i]) << std::endl;