NESCONSET, N.Y. (CBSNewYork) — A St. James man has been arrested for burglarizing a doctor’s office after he was caught trying to fill forged prescriptions at two local pharmacies on Friday, police said.

Police say 41-year-old Andre Machate tried to get a prescription filled at a Smithtown CVS shortly before 3 p.m. and fled after the pharmacist became suspicious of its authenticty.

READ MORE: 'Irresponsible:' MTA Says Mayor's Plan To Add 250 Subway Officers Isn't Enough To Combat Recent Crime

Machate then allegedly went to another CVS in Nesconset, but was arrested when he returned to pick up his prescription.

READ MORE: With Injuries Piling Up Across New York City, Mayor De Blasio Is Considering Bicycles Being Required To Have License Plates

Detectives recovered the forged prescription and a blank prescription pad that police said Machate had stolen from a doctor’s office last year.

Police said Machate broke into the doctor’s office by smashing a glass window near the front door on Nov. 28, 2011.

MORE NEWS: Bronx Man Takes It Upon Himself To Clean Up NYC Park, But City Says Not So Fast

Machate has been charged with burglary, forgery and criminal possession of stolen property.