Proving a function to be injective

Hi all,

I'll get right to the question:

Suppose you are given functions f:A->B and g:B->C such that the composite function g(f(x)) is injective, prove that f is injective.

I'm pretty sure I have it, but the last step seems a bit of a jump, and although i can't seem to find counter example to refute my proof, i'd like to make sure!

here's what i think:

Suppose x1 not= x2 for x1 and x2 in a set A

=>g(f(x1)) not=g(f(x2))

Therefore f(x1) not= f(x2) because if they WERE equal to each other, it would mean the composite function g(f(x1)) would =g(f(x2)) and we know this isn't true because it was explicitly stated that x1 not= x2 and that for the composite function to remain injective (another thing that is true at start of question) g(f(x1)) must not=g(f(x2)) with x1 not= x2.

So by contradiction f(x1) not= f(x2) and so f is injective.

Erm, it all just melts my brain reading over it, it's like it loops itself so many times...but here's hoping someone can help if i am wrong!

Edit: How do I use proper math notation here, i've seen it on a few posts, but haven't figured it out yet ;/