Bring a large pot of salted water to a boil.
Add the spaghetti and cook until al dente, about 12 minutes.
Drain the pasta, reserving 1 cup of the pasta water.
Return the pasta to the pot. Add the grated cheese, butter, black pepper and roughly ¼ cup of the reserved pasta water to the pot, stirring until combined. If necessary, add more pasta water to thin out the cheese and butter until the spaghetti is well coated.
I can't tell you how many times I've forgotten to reserve a portion of the pasta water when draining the spaghetti. The starchy water is critical to the consistency of the sauce, so while hot water will work in a pinch, avoid forgetting this step!
The cheese must be grated, rather than shredded, as the shredded consistency has the tendency to clump together when added to the pot.