Flowers for Your Grave
When a young woman is found dead under circumstances described exactly in a book written by author Richard Castle, he is brought in to provide insight into the case. When more victims turn up in similarly-accurate conditions described in his books, Castle is enlisted to assist the investigation by applying his knowledge of criminal behavior and his own books to the department's considerable skills. It turns out that the killer is actually the brother of one of the victims, only killing the others because he wanted it to look like a crazy fan killed those people. Over the period of this case Castle becomes intrigued with Detective Beckett and starts writing a manuscript about a character based on her.
Copyright: Wikipeidia