Use strncat instead of strcat to avoid problems with malformed files.