You could still lose that fight, even if your work came first, if you never published it or filed a patent for it. First to invent only holds if you reduced it to practice (either by actually inventing the thing, or boiling it down so someone reasonably skilled in the art could then invent it) within that year. You lose rights to it after that if someone else wants to patent it. There's also first to conceive stipulations. The intellectual property class I took last semester would have been a lot easier if the U.S. just went first to file (like basically everywhere else).