Encode a normal string and save it in the output file.
value to output
file to output to
0 on success, -1 on error.