Typed 'AppendString' instead of AppendLine in the function definition.
Forgot to close the file in the AppendFile routine.