Write a program to reverse a string without using built-in library functions.
Implement reverse_string(s), which receives a string and returns a new string containing the same characters in reverse order. Do not use reversed(), slicing such as s[::-1], or library reversal utilities.
The function must preserve spaces, punctuation, digits, letter case, and repeated characters. An empty string is valid input.
def reverse_string(s):