Sharps and flats can also be written in key signatures. A key signature is written at the beginning of the piece, and repeated at the beginning of each line. It gives the sharps or flats which are going to be regular in the piece.