Watch the Melody in E online guitar lesson by Joe Dalton from Fretboard Epiphanies
Here is the same idea in the Key of E. You will go through some trials and errors as you learn the craft of writing a melody. After you spend some time at this, you will probably learn to improvise some great lines. Notice the phrasing again. I'll use short, sometimes three note phrases, to make a musical statement. Then, I'll answer it with a parallel phrase or a contrary phrase. If you analyze the structure of the melody, you will find the patterns.