To take it a bit farther, think about and write down what kind of song you want to write. You said you want to write a Rock song. That's a good first step, but it is too vague. "I want to write a rock song" doesn't lead in too much of a direction.
Are you writting a Rock Ballad? A Jazz/Rock song? What kind of emotion do you want to portray in the song? These are some of the question you should ask yourself before writting. Be as descriptive as possible about the song you wish to write.
Knowing that you want to write a driving hard rock song with a bluesy feel . You now have a better idea of what to write, and/or a better idea of what to start with. A "bluesy feel" tells you that you might want to use a shuffle feel or certain type signature, and write a bluesy type melody. It also tells you what kind of chords would be good to use. Blues uses alot of dominant 7th chord (with some alterations). "Driving" tells you about the rhythm and tempo you want to use. Rhythm is the primary factor in rock music, next to melody. Those few words nearly write the song for you. Now your job becomes taking that and turning it into music.
Another important thing about describing the song you want is it give you a clear focused idea of the song you want to write. With that there is less chances of straying away from that. So keep that initial description in the back of your mind every step of the way, and after you finish each part compare it to that initial idea. Does it fit the description or does it stray away from this idea?
Straying away from the idea is not wrong, but seeing your a beginner. Keep it simple. Changing the emotion contour of your song, let alone the melody, takes some songwritting maturity to do convincingly throughout. Sticking with the idea seems to be where your at, and where you would benefit the most. As you gain some experience try changing it up alittle.
As for writting melodies. I say this is the part of the song writting process that alot of songwritters make alot more difficult than it has to be. Listen, listen, listen. Hum out your ideas and then transpose them to your guitar. Keep it simple. Alot of the best melodies are mostly quarter notes in 4/4 that move in steps from note to note. Write and have fun with it. Don't try to make your second song, the song that is going to change the world. You'll find yourself a couple years down the road with only a couple of songs and alot of fustration. You get better with experience, and the skill of songwritting is different from writting riffs. Putting those ideas together is the trade.
Have fun, everything is always better when you do. ;)
"My whole life is a dark room...ONE BIG DARK ROOM" - a.f.i.