The book was written by novelist Nicholas Sparks. The screenplay was written by Karen Jansen with input from Sparks, but is only LOOSELY based upon the book.
In the audio commentary on the DVD, Janzen states that her philosophy for writing a script based upon a book is as follows: read the book a couple times to get the “broad strokes” or “spirit” of the story. Write a detailed outline of the book. Throw the book away. Flesh out your outline making any changes you feel the need to, keeping in mind the “broad strokes” and “theme” of the original story.
Janzen went through 99 different drafts and made many changes (more were made after she turned in her final draft, on stage during filming, and in the editing room).