actual fix for the buffer overflow, use a stream... it might be slower but it definitely is safer