Normally, a program does not modify the contents of the text segment. Some operating systems mark text segments as read-only, both for improved error checking and to allow more than one process to share page frames in the text segment. For example, a library function might be used by more than one running process; it can be put into a shared page frame, as long as the operating system is sure that no process can modify that page frame.
Send you program to me by email. Attach your program. In the body of the message say (1) what operating system you used and (2) whether the system allowed you to write to the text segment.